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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select all data in one table that are not prsent in the second table?

Status
Not open for further replies.

LittleNick

Technical User
Jun 26, 2009
55
US
Hi,
I have two tables tblData1 and tblData2 with 3 columns Id, First, Last, on both. tbldata1 is the full table and tbldata2 consist of selected records of tbldata1. Now I need to filter all the data out in tblData1 that are in tblData2. for ex:

tbl1 tbl2
1 3
2 5
3
4
5

I need to have a query or view that return tbl1 as
tbl1
1
2
4

Thanks for help
 
Code:
SELECT Tbl1.*
FROM Tbl1
LEFT JOIN Tbl2 ON Tbl1.CommonField = Tbl2.CommonField
WHERE Tbl2.CommonField IS NULL

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Thanks bborissov. That was what I needed. It works great.
Thank you again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top