|
-
Aug 28th, 2001, 10:29 AM
#1
Thread Starter
Addicted Member
Does MS Access support sub-query usage
All dears,
Can I write SQL that contain sub-query for MS Access?
Thanks
-
Aug 28th, 2001, 10:45 AM
#2
Of course,
Code:
SELECT product_id, supplier_id, product_name
FROM products
WHERE supplier_id IN
(SELECT supplier_id
FROM supplier
WHERE (country = 'USA'))
Assuming that I want to get all products where the suplier is in US.
-
Aug 28th, 2001, 10:49 AM
#3
Thread Starter
Addicted Member
Thanks a lot
I wish to get the sales statistics (between start date to end date) from the database of all products. But the product name is in another table linking by oproductid, is it true to write the following:
Code:
Public Sub GetSalesData(ByVal StartDate As Date, ByVal EndDate As Date)
sql = "SELECT Product.ProductID AS " & lProductID & ", " & _
"Product.ProductName AS " & lProductName & ", " & _
"SUM(OutStock.Quantity) AS " & lOutQuantity & " " & _
"FROM Product, OutStock " & _
"WHERE Product.ProductID=OutStock.ProductID " & " " & _
"AND OutStock.Date BETWEEN #" & StartDate & "# AND #" & EndDate & "# " & _
"GROUP BY Product.ProductID, Product.ProductName"
:
:
Can you give me advice. Thanks again
-
Aug 28th, 2001, 10:57 AM
#4
The code you have looks ok, but in your case this is not a subquery, but a simple join.
-
Aug 28th, 2001, 11:03 AM
#5
Thread Starter
Addicted Member
Originally posted by Serge
The code you have looks ok, but in your case this is not a subquery, but a simple join.
Yes, I originally thought of using sub-query, so asking you the question bfore. Now if this method is OK, I will choose this for simplicity. I wish to say deep thanks to yr useful help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|