Click to See Complete Forum and Search --> : sql question


pouncer
October 5th, 2008, 10:51 AM
If I have

table A:

ORD | ADDRESS (field names)
1 | sdfdsg
2 | fgfdgfd
3 | fdgfdg
4 | fdgfdgh

table B:
ORD | PROD | QTY
1 | P1 | 10
1 | P2 | 5
3 | P4 | 1

what kind of query could i use to show order numbers from A which have no corresponding details in B - it should return orders 2 and 4

any ideas guys?

hspc
October 5th, 2008, 11:19 AM
These queries will return the same required result:
Select TableA.*
from TableA
left join TableB on TableA.itemid=TableB.itemid
Where TableB.itemId is null

Select * from TableA
where not exists (Select ItemID from TableB where ItemID = TableA.itemid)

pouncer
October 5th, 2008, 01:57 PM
Thanks alot!