This post was kindly contributed by AFHood Analytics Group - Blogs » SAS - go there to comment and to read the full post. |
We write a LOT of SQL here and although SQL is a powerful database language, it can be tedious. So here is one tip for shortening all that typing.
Typical join sytax:
select some_columns
from one_table join another_table on one_table.column_1 = another_table.column_1 and one_table.column_2=another_table.column_2
where some_column > someother_column ;
Not too bad, right?
In order for this tip to work, you must be joining on columns with the same name (ie. column_1 and column_2 have the same name in both tables).
Here it is:
select some_columns
from one_table join another_table using (column_1, column_2)
where some_column > someother_column ;
Now, in our example it’s not a drastic difference in coding, but as any programmer knows, this shorthand example doesn’t accurately represent the real world. So give this syntax a try on your next project and let us know if it doesn’t save you some typing.
This post was kindly contributed by AFHood Analytics Group - Blogs » SAS - go there to comment and to read the full post. |