Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Use `EXISTS` when you only need to test whether a related row exists, not return one output row per match.
Return all rows from both tables, filling NULLs on either side when there is no matching row.
Return all rows from the right table and matching rows from the left, filling NULL where no match exists.
Return all rows from the left table and matching rows from the right, filling NULL where no match exists.
Put right-table filters in the `ON` clause when you want to keep unmatched left-side rows.
Produce every possible pairing of rows from two tables using `CROSS JOIN`.
Reference the same table twice using aliases to compare or relate rows within the same dataset.
Combine rows from two tables when matching keys exist in both tables.
Use `LATERAL` (or `CROSS APPLY` on SQL Server) to let a subquery reference columns from the preceding table in the `FROM` clause.
Use a join inside an `UPDATE` statement to copy or derive values from a related table.