Skip to main content

What is the difference between LEFT, RIGHT, INNER and OUTER JOIN?

I have been working with a lot of SQL lately. I wouldn’t label myself an expert, but I have been finding my way around a lot easier the more I work with it.

I have been working a lot with normalizing data and writing queries that reference multiple tables. When referencing multiple tables, it is common to write a join. Here is a very small overview that explains the difference between Left, Right, Inner and Outer Join:

Join and Inner Join
Only show records that are common to both tables. Whether the records are common is determined by the fields in join clause
Left Join and Left Outer Join
Show all records from left table regardless of the existance of matching records in the right table.
Right Join and Right Outer Join
Show all records from the “RIGHT” table and only matching records from the first or “LEFT” Table.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *