|
||
| Lesson 7
Objective |
Use the sub-SELECT statement
Create sub-SELECT statement using the IN keyword. |
|
| Building Sub Select Statement
In the previous lesson, if there was more than one row in the Publishers table with the correct state ("CA"), the query would use commas, as follows: Create a sub-SELECT statement using the IN keyword SELECT Title FROM Titles WHERE pub_id IN ('1389','0736','0877')
Any publisher in the Titles table with a pub_id matching any of the values in the list will appear here.
Sub Select Statement Exercise
This is a good way to use one table as a controlling key to another. In this case, the Publishers table is controlling the output for the query against the Titles table. One final note: be sure to enclose the sub-SELECT in parentheses. This is required to make the engine aware of the statement and its start and end point.
Click the link below to work on the
Sub Select Statement Exercise .
Before you begin the exercise, read about engine support for sub-SELECT statements. Then, complete the exercise. |
||
|
|
||