Joins in SQL are used to combine data from two or more tables based on a related column. An "Inner Join" retrieves only the rows where there is a match in both tables, while a "Left Join" returns all rows from the left table and the matched rows from the right table, filling unmatched rows with NULL. Conversely, a "Right Join" returns all rows from the right table and matched rows from the left, also filling unmatched rows with NULL. "Full Outer Join" combines the results of both Left and Right Joins, including all unmatched rows from both tables with NULLs where applicable. Joins are essential for relational databases to effectively link and query data across multiple tables.
Combines rows from two tables where there is a match in both tables. Only matching rows are returned.
Returns all rows from the left table, and the matched rows from the right table. Unmatched rows will show NULL.
Returns all rows from the right table, and the matched rows from the left table. Unmatched rows will show NULL.
Returns all rows from both tables, with NULLs where there is no match.
A Cross Join produces a Cartesian product of the two tables. Every row from the first table is combined with every row from the second table.
A Union Join combines the results of two SELECT queries, removing duplicate rows by default. Each SELECT query must have the same number of columns, with similar data types.