Re: Query condition
- From: Robin <Robin@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 Oct 2007 01:30:01 -0700
Allen,
I've been using the sub query you suggested and it works well. However,
i've realised that it would be beneficial to show all of the order lines that
belong to the order. You mentioned in your last post that i should use a
grouping on the orderID? Can you explain this in a bit more detail?
Thanks
Robin
"Allen Browne" wrote:
The way the query is formatted, it will show only the 57 product unless you.
adjust it further (e.g. grouping on the OrderID field, and using Where in
the Total row under the ProductID.)
John Spencer also posted a good reply. It's worth experimenting with his
suggestion too.
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Robin" <Robin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:4821454E-A79C-4C00-BD93-6D631127E50E@xxxxxxxxxxxxxxxx
Hi Allen,
I tried your suggestion and i've got a result but the query is only
showing
productID 57. Is this correct or should both productID's be listed?
Robin
"Allen Browne" wrote:
Because you need to query 2 different *rows* of data, you could use a
subquery to choose the other one.
This kind of thing:
SELECT OrderDetail.*
FROM OrderDetail
WHERE (OrderDetail.ProductID = 57)
AND EXISTS (SELECT OrderID
FROM OrderDetail AS Dupe
WHERE Dupe.OrderID = OrderDetail.OrderID
AND Dupe.ProductID = 58);
If subqueries are new, here's an introduction:
http://allenbrowne.com/subquery-01.html
"Robin" <Robin@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:50605C87-896C-45B3-977B-51E8EB340EF8@xxxxxxxxxxxxxxxx
Hi All,
I have two tables for managing our sales orders. One has the order
header
info such as customer name, account number, etc and the other stores
the
order line info such as productID, unit price, qnty, etc. The tables
have
a
one to many relationship and are joined using the OrderID.
I need to create a query to list all the sales orders that include both
productID 57 and 58 but i can't quite get my head round it! If i put
"57
or
58" in the criteria box it gives me all of the orders that include
either
57
or 58 whereas i need to know the orders that include both!
Thx in advance.
Rob
- Follow-Ups:
- Re: Query condition
- From: Allen Browne
- Re: Query condition
- References:
- Re: Query condition
- From: Allen Browne
- Re: Query condition
- From: Allen Browne
- Re: Query condition
- Prev by Date: Updatable SQL 2000 partitioned view not updatable in Access
- Next by Date: Re: max no group
- Previous by thread: Re: Query condition
- Next by thread: Re: Query condition
- Index(es):
Relevant Pages
|