How do I decide when to use right joins/left joins or inner joins Or how to determine which table is on which side?

Yes, it depends on the situation you are in.

Why use SQL JOIN?

Answer: Use the SQL JOIN whenever multiple tables must be accessed through an SQL SELECT statement and no results should be returned if there is not a match between the JOINed tables.

Reading this original article on The Code Project will help you a lot: Visual Representation of SQL Joins.

alt text

Also check this post: SQL SERVER – Better Performance – LEFT JOIN or NOT IN?.

Find original one at: Difference between JOIN and OUTER JOIN in MySQL.


In two sets:

  • Use a full outer join when you want all the results from both sets.

  • Use an inner join when you want only the results that appear in both sets.

  • Use a left outer join when you want all the results from set a, but if set b has data relevant to some of set a's records, then you also want to use that data in the same query too.

Please refer to the following image:

SQL Joins