Goal
When you have completed this chapter, you will be able to nest a SELECT statement within another SELECT statement to retrieve specified data.
Summary
An SQL request that is nested inside another SELECT statement is called a subquery. The subquery returns a set of values for use in the outer SELECT statement:
select from where column = ◄───────────┐ │ (select ────┘ from where column = ◄───────────┐ │ (select ────┘ from where column = ));
You nest SELECT statements when you want to use data from one table as part of the criteria of another table. A subquery is often used in conjunction with predicates IN and EXISTS.
This section contains the following topics:
SELECT Statement in a WHERE Clause
Using an Aggregate Function in a Nested SELECT Statement
Things to Remember about Subqueries
|
Copyright © 2014 CA.
All rights reserved.
|
|