SQL & Relational Databases (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What are the different types of SQL Joins (INNER, LEFT, RIGHT, FULL, CROSS)?
junior LevelCode ExampleDatabases & SQL
In Simple Words:
- INNER JOIN: Returns only rows where there is a match in both tables.
- LEFT (OUTER) JOIN: Returns all rows from the left table, plus matched rows from the right table (unmatched right columns return
NULL). - RIGHT (OUTER) JOIN: Returns all rows from the right table, plus matched rows from the left table.
- FULL (OUTER) JOIN: Returns rows when there is a match in either the left or right table.
- CROSS JOIN: Produces the Cartesian product of two tables ($N \times M$ rows).
text
Visual Venn Representation:
INNER JOIN: [ (A ∩ B) ]
LEFT JOIN: [ (A + (A ∩ B)) ]
FULL OUTER: [ (A ∪ B) ]
CROSS JOIN: [ A × B (Cartesian Product) ]