Alison Balteramp;#039;s Mastering Microsoft Office Access 1002003 [Electronic resources]

Alison Balter

نسخه متنی -صفحه : 544/ 193
نمايش فراداده

Subqueries

Subqueries allow you to embed one SELECT statement within another. By placing a subquery in a query's criteria, you can base one query on the result of another. Figure 11.38 shows an example. The query pictured finds all the clients without projects. The SQL statement looks like this:

SELECT DISTINCTROW tblClients.ClientID, tblClients.CompanyName FROM tblClients WHERE tblClients.ClientID Not In (Select ClientID from tblProjects)

Figure 11.38. A query containing a subquery.

This query first runs the SELECT statement SELECT ClientID from tblProjects. It uses the result as criteria for the first query.