0% found this document useful (0 votes)
2 views1 page

JOINS Fundamentals

The document explains three types of SQL joins: INNER JOIN, LEFT JOIN, and FULL JOIN. INNER JOIN returns only matching rows from both tables, LEFT JOIN returns all rows from the left table and matched rows from the right, while FULL JOIN returns all records with matches in either table. Each join type is illustrated with SQL query examples and their corresponding results.

Uploaded by

omniscienthound9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

JOINS Fundamentals

The document explains three types of SQL joins: INNER JOIN, LEFT JOIN, and FULL JOIN. INNER JOIN returns only matching rows from both tables, LEFT JOIN returns all rows from the left table and matched rows from the right, while FULL JOIN returns all records with matches in either table. Each join type is illustrated with SQL query examples and their corresponding results.

Uploaded by

omniscienthound9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

JOINS Fundamentals

1. INNER JOIN:

This join returns only the rows that have matching values in both tables.

SELECT a.column1, b.column2

FROM table_a a

INNER JOIN table_b b

ON a.id = b.id;

This query retrieves rows where the id in table_a matches the id in table_b.

2. LEFT (OUTER) JOIN:

This returns all rows from the left table and the matched rows from the right table. If there is
no match, NULLs are returned for columns from the right table.

SELECT a.column1, b.column2

FROM table_a a

LEFT JOIN table_b b

ON a.id = b.id;

This returns all records from table_a and the matched records from table_b. Rows from
table_a without a match in table_b will show NULL for columns from table_b.

3. FULL JOIN (or FULL OUTER JOIN):

This returns rows when there is a match in one of the tables. It combines the results of both
LEFT and RIGHT joins.

SELECT a.column1, b.column2

FROM table_a a

FULL OUTER JOIN table_b b

ON a.id = b.id;

This will return all records when there is a match in either table. If there is no match, NULL values
are returned for non-matching columns from the other table.

You might also like