sqlcmd.net validated sql reference

#join

Commands grouped around the same concept, pattern, or recurring problem.

15 commands with this tag Browse related patterns quickly
intermediate filtering MySQL MariaDB SQL Server PostgreSQL SQLite

Avoid Duplicate Parent Rows With EXISTS

Use `EXISTS` when you only need to test whether a related row exists, not return one output row per match.

advanced joining SQL Server PostgreSQL SQLite

Combine All Rows From Both Tables With FULL OUTER JOIN

Return all rows from both tables, filling NULLs on either side when there is no matching row.

advanced deleting MySQL MariaDB SQL Server PostgreSQL SQLite

Delete Rows Using A Join Condition

Remove rows from one table based on matching rows in another table.

intermediate date MySQL MariaDB SQL Server PostgreSQL SQLite

Detect Overlapping Date Ranges

Find rows whose date or timestamp intervals intersect by checking that neither range ends before the other begins — using the `OVERLAPS` operator in PostgreSQL or a manual comparison in other engines.

advanced joining MySQL MariaDB SQL Server PostgreSQL SQLite

Fetch Rows Including Unmatched From Right Table

Return all rows from the right table and matching rows from the left, filling NULL where no match exists.

intermediate joining MySQL MariaDB SQL Server PostgreSQL SQLite

Fetch Rows Including Unmatched With LEFT JOIN

Return all rows from the left table and matching rows from the right, filling NULL where no match exists.

intermediate joining MySQL MariaDB SQL Server PostgreSQL SQLite

Filter LEFT JOIN Matches In The ON Clause

Put right-table filters in the `ON` clause when you want to keep unmatched left-side rows.

intermediate joining MySQL MariaDB SQL Server PostgreSQL SQLite

Find Rows With No Match Using An Anti-Join

Return rows from one table that have no corresponding row in a second table using a LEFT JOIN with a NULL check.

advanced joining MySQL MariaDB SQL Server PostgreSQL SQLite

Generate All Row Combinations With CROSS JOIN

Produce every possible pairing of rows from two tables using `CROSS JOIN`.

advanced joining MySQL MariaDB SQL Server PostgreSQL SQLite

Join A Table To Itself With A Self-Join

Reference the same table twice using aliases to compare or relate rows within the same dataset.

intermediate joining MySQL MariaDB SQL Server PostgreSQL SQLite

Join Tables On A Range Condition

Join two tables using a comparison other than equality — such as `BETWEEN` or `<` — to match rows based on ranges rather than exact values.

intermediate joining MySQL MariaDB SQL Server PostgreSQL SQLite

Join Tables With INNER JOIN

Combine rows from two tables when matching keys exist in both tables.

advanced joining MySQL SQL Server PostgreSQL

Reference Outer Columns Inside a Subquery With LATERAL

Use `LATERAL` (or `CROSS APPLY` on SQL Server) to let a subquery reference columns from the preceding table in the `FROM` clause.

advanced updating MySQL MariaDB SQL Server PostgreSQL SQLite

Update Rows Using Values From Another Table

Use a join inside an `UPDATE` statement to copy or derive values from a related table.

intermediate composition MySQL MariaDB SQL Server PostgreSQL SQLite

Use an Inline Table of Constant Values

Supply a small set of constant rows directly inside a query using a `VALUES` derived table — no temporary table or CTE required.