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

Reverse the Result of SQL Statement

Status
Not open for further replies.

simeybt

Programmer
Nov 3, 2003
147
GB
All,
What i looking to do is to get all the records on one table that don't have a matching code in an other table. ie
SELECT A_Table.*
FROM A_Table, B_Table
WHERE A_Table.code <> B_Table.code;

but this doesn't work

Any ideas
 
You should be using a Left Join to accomplish this:

Code:
SELECT A_Table.*
FROM A_Table LEFT JOIN B_Table ON A_Table.code = B_Table.code 
WHERE IsNull(B_Table.Code);

This should give you what you are looking for.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top