October 30, 2006 at 10:57 pm
Hi all,
I have table called 'tblMaster' with one field 'ItemCode' and another table is tblTrans with one field 'ItemCode'
tblMaster Records
ItemCode
I1
I2
I3
I4
I5
tblTrans Records
I2
I3
I want a query that should return the records from tblMaster- I1,I4,I5
Any sample query ?
Thanks
Rgds
Senk
October 30, 2006 at 11:15 pm
This should work:
SELECT ItemCode
FROM tblMaster
WHERE ItemCode NOT IN (SELECT ItemCode FROM tblTrans)
Enjoy!
A Brown
Manage all of your backups in one simple job using this script.
October 30, 2006 at 11:21 pm
Thank you..
October 31, 2006 at 8:32 am
Or you can use this (I like it more than IN clause and at least sometimes it works a lot quicker - didn't do any extensive testing though):
SELECT M.ItemCode
FROM tblMaster M
LEFT JOIN tblTrans T ON T.ItemCode=M.ItemCode
WHERE T.ItemCode IS NULL
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply