Day 6. Using Subqueries
One of the capabilities of SQL is to nest one SQL query within another. If you want to select data from one table based on a list of values, you could enter the WHERE condition values manually using an IN clause, or you could use a second SQL SELECT statement to get the values. When you use the result set from one query to supply another query's conditions, you are using a subquery. Subqueries enable you to perform in one step what otherwise would require multiple steps. In today's lesson, you will learn
How to write subqueries
Why to use subqueries: what they do and why they're useful
Subqueries returning a single value
Subqueries returning multiply values
Using the IN clause with a subquery
Correlated subqueries
Using WHERE ...
Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.