SQL – Joins

Joins – as the word suggests, it about joining. So it two “things”. In RDBMS, the main “thing” is a table so a join is between two or more tables.

Two things to be careful about

  • make sure you include all the required conditions
  • make sure the datasets you are joining are at the same level

I just introduced a new term above. You don’t need to include the whole tables in a join. You can have a subset of data from a tables. Now again the subset is a wide interpretation of anything you can do with one or more Select.

Most RDBMS allows you to do the joins two ways

  • Using JOIN keyword
  • Using just the where clause and putting the JOIN conditions along with the filter

One tip about where clause conditions . Start the conditions so that you get the shortest dataset as soon as possible. You aim should be to perform as many operations on the shortest dataset or to put it other way, lowest number of operations on the larger datasets.

I think Teradata doesn’t allow joining tables using Where but I will leave it for you to check.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.