Results 1 to 8 of 8
Thread: Distinct and sub-queries?
Dec 9, 2009, 11:05 #1
- Join Date
- Feb 2006
- Bedford, UK
- 0 Post(s)
- 0 Thread(s)
Distinct and sub-queries?
I'm hoping you can point me in the general direction of what I need to do.
I've got 2 tables (abbreviated):
orders: order_id, id, sessionid
products: id, title, ref
What I need is a select query which will pull all the info from both but display only one row per orders.id.
I think I need to use DISTINCT but I've read that it doesn't work with JOINs - is there a way of doing a subquery to pull the rest of the information out?
I know this is wrong but something like:
SELECT DISTINCT orders.id (SELECT orders.sessionid, products.id, products.title from orders, products) WHERE sessionid='$sessionidnow'
Any suggestions welcomed!