Summary
This chapter has explored subqueries, including the following:
What subqueries are and where they appear
How simple and correlated subqueries work
Hints on when to use subqueries and when to stick with joins
Subquery rules, restrictions, and limitations
After these preliminaries, we looked at operators:
IN or NOT IN can return any number of rows
Comparison operators (=, >, etc.) must return no more than one row
EXISTS and NOT EXISTS test existence and are mostly used with correlated subqueries
Finally, we considered some advanced issues:
Subqueries within subqueries—nested subqueries
Subqueries in UPDATE, DELETE, and INSERT statements
Subqueries in SELECT and FROM
Now that you can write plain and fancy queries using joins and subqueries, you ...
Get Practical SQL Handbook, The: Using SQL Variants, Fourth 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.