ACC1x: Using Subquery to Simulate a SQL Sub-SELECT Statement 1.xLast reviewed: April 2, 1997Article ID: Q96464 |
The information in this article applies to:
SUMMARYThis article explains how to use a subquery to simulate a SQL sub-SELECT statement. The procedure below uses the sample database NWIND.MDB to generate a list of customers who have used all three shippers to deliver their orders.
MORE INFORMATIONYou either can create a query (called Query1) based on the Customers and Orders tables and another query (called Query2) based on Query1, or you can enter the equivalent SQL statements. This article contains procedures for both methods.
Creating Query1To create Query1 interactively, use the following steps:
SELECT DISTINCT Customers.[Customer ID], Orders.[Ship Via] FROM Customers, Orders, Customers INNER JOIN Orders ON Customers.[Customer ID] = Orders.[Customer ID]; Creating Query2Create a second query (subquery) based on Query1. To create Query2 interactively, use the following steps:
SELECT Query1.[Customer ID] FROM Query1 GROUP BY Query1.[Customer ID] HAVING (((Count(Query1.[Ship Via]))=3));When you run Query2, a list of those customers who have used three different shippers is displayed.
|
Additional query words: sub-query sub-select SQL relational
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |