Wednesday, January 1, 2025
HomeTechSQL: JOIN vs LEFT OUTER JOIN

SQL: JOIN vs LEFT OUTER JOIN

  • JOIN (INNER JOIN): Returns rows where there is a match in both tables.
  • LEFT OUTER JOIN: Returns all rows from the left table and matching rows from the right table; unmatched rows in the right table are filled with NULL.

Example:

sql
-- JOIN
SELECT * FROM A INNER JOIN B ON A.id = B.id;

-- LEFT OUTER JOIN
SELECT * FROM A LEFT JOIN B ON A.id = B.id;

RELATED ARTICLES

Leave a Reply

- Advertisment -

Most Popular

Recent Comments