JOINS Fundamentals
JOINS Fundamentals
1. INNER JOIN:
This join returns only the rows that have matching values in both tables.
FROM table_a a
ON a.id = b.id;
This query retrieves rows where the id in table_a matches the id in table_b.
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.
FROM table_a a
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.
This returns rows when there is a match in one of the tables. It combines the results of both
LEFT and RIGHT joins.
FROM table_a a
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.