Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Help Show OrderReferenceID Once

Status
Not open for further replies.
Mar 17, 2005
147
US
Hi and thanks in advance.
I have a query, the works, and it basically shows the order information from a typical e-commerce database.
Now when I run this query, and for this example lets say I am the customer and I order 3 distinct items in various quantity. Now when I run the query it shows all three distinct records, but is there anyway to run the query, and show the OrderReferenceID only once and the 2 other records under this which would be the first that shows the OrderReferenceID???

SELECT DISTINCT DetailOrderID, OrderReferenceID, UserID, OrderUserID, DetailProductName, DetailQuantity, DetailPrice, OrderShipping, OrderTotal, OrderDate, Firstname
FROM Orders o, OrderDetails d, Users u
WHERE o_OrderUserID = u.UserID and O.OrderReferenceID = d.DetailOrderID
 
This part:
Code:
FROM Orders o, OrderDetails d, Users u
WHERE o.OrderUserID = u.UserID [b]and O.OrderReferenceID = d.DetailOrderID[/b]

... means that DetailOrderID and OrderReferenceID will always be the same in results. So you can remove one (preferably OrderReferenceID because it is joined) from DISTINCT list.

Formatting like "show repeated grouping value only once" is possible with SQL, but client-side is much better place to do that.

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top