SQL Subqueries
Nested queries — correlated, EXISTS, IN, ANY, ALL, scalar subqueries. This category documents 27 SQL subqueries entries, and each page gives you the full syntax, the parameter list, the return value, and a runnable example tested against MySQL, PostgreSQL, SQL Server, and SQLite. The entries are: Scalar Subquery, Correlated Subquery, EXISTS, IN Subquery, ANY / ALL, DERIVED TABLE (Subquery in FROM), LATERAL Subquery (PostgreSQL), Subquery in SELECT, Subquery in HAVING, Correlated UPDATE with Subquery, Correlated DELETE with Subquery, Nested Subqueries, Multi-row Subquery Comparisons, Correlated Subquery in SELECT (Row Comparison), NOT IN vs NOT EXISTS, Subquery Factoring / Materialization, Subquery in ORDER BY, Subquery in WITH CHECK OPTION, Lateral Subquery in WHERE, Double-Nested Subquery, Subquery with UNION inside, Inline Subquery Performance, Subquery with HAVING EXISTS, Subquery in CASE Expression, CAST in Subquery, SQL NOT IN with NULL Handling, SQL EXISTS with Correlated Subquery. Not sure where to start? Scalar Subquery and Correlated Subquery are the most commonly used entries in this category. You can also search across every category from the search page, browse the complete A–Z index, or try any of these statements live in the SQL playground.