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

Toughie Query Problem

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
I am working with two tables (A and B).

TableA

ITNum Loc
1012 East
1023 East
1035 West
1095 West

TableB
PTNum Ring
1012 C
1035 D

I only want to display the records from TableA that do not have a corresponding record in TableB. ITNum=PTNum

I can do this if the column names were the same however, since they are different, I can not get it working.

Thx
 
Code:
select * from tableA
where not exists (
select * from tableb
where tableA.ITNum = tableB.PTNum)
 
alternative method:
Code:
select A.ITNum 
     , A.Loc
  from TableA as A
left outer
  join TableB as B
    on A.ITNum 
     = B.PTNum
 where B.PTNum is null

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top