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!

Help with "NOT IN" Select subquery

Status
Not open for further replies.

pnsmack

Programmer
Feb 12, 2002
12
US
Hey All,

I have a query :

select [empid] from TABLE_A where [empid] NOT IN (select [empid] from TABLE_B);

I get NO results even though there are differing values between the 2 tables.

I tried reversing the query, e.g.--

select [empid] from TABLE_B where [empid] NOT IN (select [empid] from TABLE_A);

And I got matching results !
The 2 "empid" fields are of the same data type, and there are values in Table A which are NOT in Table B.
Conversely, there are values in Table B which are NOT in Table A.

Ever heard of anything like this ?
Thanks in advance !
Paul
 
try this:
Code:
select * from TABLE_A where NOT EXISTS (select * from TABLE_B where table_a.empid = table_b.empid);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top