Query help

T

Tom

I have one last type of problem that I'm working. This
problem references the sample database that comes with
Access called "Northwinds".

This problem involves joining multiple tables and I have
to write this query free hand and not with the SQL design
tool.

My problem is determining "How many orders
include "Tofu"?"

The query that I created is ....
SELECT COUNT OrderID
WHERE OrderID =
(SELECT OrderID
FROM Order Details
WHERE ProductID =
(SELECT ProductID
FROM Products
WHERE ProductName = 'Tofu'));
but it is not working ... can someone give me some advice
as to how to proceed?

Thanks - Tom
 
C

Cheryl Fischer

Tom,

If what you want is a count of Orders in which one of the products ordered
was "Tofu", this should work:

SELECT Count([Order Details].[OrderID]) AS CountTofu
FROM Products INNER JOIN [Order Details]
ON Products.ProductID = [Order Details].ProductID
WHERE (((Products.ProductName)="tofu"))
WITH OWNERACCESS OPTION;


Here is a hint: You can always use the Query Designer to create a query and
then view the SQL code for it by selecting View|SQL View from the menu in
the designer. Then you can cut and paste the SQL into your VBA code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top