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

Quey to return records in table A not in table B

Status
Not open for further replies.

RLA

Instructor
Feb 22, 2002
22
US
Hi --
I am trying to write a query that returns records in table A that are not in table B. It seems like you should be able to do it in a union query but I haven't figured out how. Please help! Thanks.
 
SELECT Table1.Field1, Table2.Field1
FROM Table1 LEFT JOIN Table2 ON Table1.Field1 = Table2.Field1
WHERE (((Table2.Field1) Is Null));

Index related fields also...

htwh... Steve Medvid
"IT Consultant & Web Master"
e-Mail: Stephen_Medvid@GMACM.com

Chester County, PA Residents
Please Show Your Support...
 
use not in

select * from tableA where indexd filed not in ( select Indexed field from tableb)

or us a left join and look for nulls

select tbl1.fld1, tbl2.fld1
from tbl1 left join tbl2 ON tbl1.fld1 = tbl2.fld1
where (((tbl2.fld1) is null));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top