Lesson 13. Working with Subqueries

In this lesson, you learn what subqueries are and how to use them.

Understanding Subqueries

SELECT statements are SQL queries. All the SELECT statements you have seen thus far are simple queries: single statements retrieving data from individual database tables.

New Term: Query

Any SQL statement. However, this term is generally used to refer to SELECT statements.

SQL also enables you to create subqueries—queries that are embedded into other queries. Why would you want to do this? The best way to understand this concept is to look at a couple examples.

Filtering by Subquery

The database tables used in all the lessons in this book are relational tables. (See Appendix B, “The Example Tables,” for a description ...

Get Sams Teach Yourself Microsoft® SQL Server T-SQL in 10 Minutes, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.