SQL Right versus Left Outer Joins - Now which table returns all the rows? | Essential SQL
May 11, 2024
An outer join is a join where all rows from one table are included in the result, but if there isn't a match in the other, then a NULL is returned.
The difference between left and right outer joins has to do with table position. A left and right refer to where a table resides in relationship to the FROM clause. The left table is the table that is in the FROM clause, or left of the join condition, the join clause here. And a right table is on the right side of the join clause.
When we speak of a left outer join, what we're saying is, take all the rows from the left table, and join them to rows on the right table. And conversely, when we start learning about right outer joins, what we'll be saying is take all the rows from the right table, and match them where you can to rows from the left table.
Hopefully, now you have a good understand between the difference of left, and right outer joins. Remember that the left table is referring to the table in the FROM clause, and the right table is the table that is after the join clause. The key difference between a left outer join, and a right outer join is that in a left outer join it's the table in the FROM clause whose all rows are returned. Whereas, in a right outer join we are returning all rows from the table specified in the join clause.
Show More Show Less #Computer Education
