Checking for Membership

"Checking for membership" actually means that you want to return a set of data that matches another set of values that are specified in the WHERE clause. To work with a subquery that returns more than one value, you can modify the comparison operator as discussed in the previous section, or you can use the IN or the EXISTS clause of the SELECT statement.

So far, all the subqueries that you have seen have been written for you. In this section, you will write a subquery from scratch. Along the way, I will give you a couple of tips to help make the process easier.

Note

The result of a subquery that is used with an IN clause is a list of zero or more values. After the subquery returns the resulting information, the outer query ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second 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.