SQL Joins
Joins are used to combine data from different tables in a relational database. The relationship is usually defined by a foreign key in one table pointing to a primary key in another.
Join Types
- INNER JOIN: Returns records that have matching values in both tables.
- LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table.
- RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table.
- FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table.
- CROSS JOIN: Returns the Cartesian product of the two tables (every row from table A joined with every row from table B).
- SELF JOIN: A regular join, but the table is joined with itself.