May 2005
Beginner
480 pages
11h 1m
English
To this point, I've used a single SELECT statement to retrieve data from one or more tables. This chapter describes nested queries, which let you retrieve or modify data based on another query's result.
A subquery, or subselect, is a SELECT statement embedded in another SQL statement. You can nest a subquery in:
The SELECT, FROM, WHERE, or HAVING clause of a SELECT statement
Another subquery
An INSERT, UPDATE, or DELETE statement
In general, you can use a subquery anywhere an expression is allowed, but your DBMS might restrict where they can appear. This chapter covers subqueries nested in a SELECT statement or another subquery; Chapter 10 covers subqueries embedded in INSERT, UPDATE, and DELETE statements.
Read now
Unlock full access