SQL Shack · August 03, 2021
How to write subqueries in SQL?
This article introduces SQL subqueries through examples of embedding a query within another SQL statement. It explains how subqueries can supply scalar values, sets of values or derived tables and how they can be used in different clauses.
The examples examine filtering and retrieving information based on related data. The discussion also highlights performance considerations when subqueries are evaluated for individual rows, encouraging developers to consider alternatives such as joins where appropriate.