|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
||||
|
||||
|
sql join question
hi,
i'm almost ashamed to ask, i should be able to get this going on my own, but here goes any way...apologies for using the php tags - the fixed width font makes layout easier !! two tables - products and where orders orders.productId = products.Id PHP Code:
i want to write a query which shows each product in the table once, and any order quantities against each line where orderId ='001' so the output looks like this. PHP Code:
i remain confident that your thoughts will prove invaluable, and thank you in advance for any time you spend on this.
__________________
rgds bdjt |
|
#2
|
|||
|
|||
|
You're right, you should have gotten this
![]() Code:
select p.id, p.productName, p.price, ISNULL(o.OrderId,''), ISNULL(o.qty,'') from products as p,orders as o WHERE p.id *= o.productid and o.orderid = '001' order by p.id If you just do a left outer join it still grabs the = row you want if the item exists in the left part of the join. easy enough ne? Last edited by unatratnag : August 20th, 2003 at 08:32 PM. |
|
#3
|
||||
|
||||
|
unatratnag
thanks for your answer - i double posted elsewhere and got much the same answer, so i know it would have worked. thanks again. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > sql join question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|