![]() ![]() The Orders table is not even in the main query. The subquery goes in brackets, without a semicolon of its own. If it finds any, the customer is excluded by the NOT EXISTS. The subquery finds any orders for that customer in the period. To decide whether to include the customer, it runs the subquery. When the main query runs, Access examines each record in the Customers table. The subquery (everything inside the brackets) selects Order ID from the Orders table, limited by two criteria: it has to be the same customer as the one being considered in the main query, and the Order Date has to be in the last 90 days. It is limited by the WHERE clause, which contains the subquery. The main query selects two fields (ID and Company) from the Customers table. WHERE Orders.CustomerID = Customers.CustomerID wants to hound customers who have not placed any orders in the last 90 days: Identifying what is NOT thereĪ sales rep. The best way to grasp subqueries is to look at examples of how to use them. There will be some tidying up to do, but that's the simplest way to create a subquery. If SQL is a foreign language, you can mock up a query like the subquery you need, switch it to SQL View, copy, and paste into SQL View in your main query. ![]() The statement is in SQL ( see'quell) - Structured Query Language - the most common relational database language, also used by MySQL, SQL Server, Oracle, DB2, FoxPro, dBase, and others. Line endings and brackets are optional.Ī subquery is a SELECT query statement inside another query.Īs you drag fields and type expressions in query design, Access writes a sentence describing what you asked for. It returns 3 fields from 1 table, applies criteria, and sorts the results: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |