Sometimes it may not be possible to retrieve the results that you need from a simple Select statement. At times, you might need to create a Select statement and compare the results to that of another statement. In that case, you would want to use subqueries. A subquery is a query that is nested inside another query. There are two types of subqueries that you can use: The In Operator The In operator is used in a Select statement primarily to specify a list of values to be used with a primary query. A classic example is if you wanted to find all your customers who lived in California. You could write a Select statement using the In operator to accomplish that: Select * From Customers Where CustomerState In ("Ca") This statement would effectively return all the customers who live in the state of California, assuming you had a field for state. The Embedded Select Statement An Embedded Select statement is used when you want to perform a query within the where clause of a primary query. Suppose you wanted to see a list of customers who have completed orders for the week. Select * From Customers Where CustomerID In (Select Distinct CustomerID From Orders) |