Joins in SQL Server are used to combine rows from two or more tables based on related columns between them. Here are the main types of joins:
INNER JOIN: Returns only the rows where there is a match in both tables.
LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table, and the matched rows from the right table. If there's no match, the result is NULL from the right side.
RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the right table, and the matched rows from the left table. If there's no match, the result is NULL from the left side.
FULL JOIN (or FULL OUTER JOIN): Returns rows when there is a match in one of the tables. This means it returns all rows from the left table and right table, with NULLs where there is no match.
CROSS JOIN: Returns the Cartesian product of the two tables, meaning it returns all possible combinations of rows.
SELF JOIN: A regular join where a table is joined with itself. It's useful for querying hierarchical data or comparing rows within the same table.
These are the most common joins used in SQL Server. Would you like to see an example of a specific join or explore something more complex?