Using the Outer join
Another class of join is known as the OUTER JOIN
. In OUTER JOIN
, the results might contain both matched and unmatched rows. It is for this reason that beginners might find such joins a little confusing. However, the logic is really quite straightforward.
The following are the three types of Outer joins:
- The PostgreSQL
LEFT OUTER JOIN
(or sometimes calledLEFT JOIN
) - The PostgreSQL
RIGHT OUTER JOIN
(or sometimes calledRIGHT JOIN
) - The PostgreSQL
FULL OUTER JOIN
(or sometimes calledFULL JOIN
)
Left outer join
Left outer join returns all rows from the left-hand table specified in the ON
condition, and only those rows from the other tables where the joined fields are equal (the join condition is met). If the condition is not met, the ...
Get PostgreSQL Development Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.