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

QUERY QUESTION

Status
Not open for further replies.

bakerm

Programmer
Apr 25, 2000
53
US
Hello.

I have what is probably a very basic SQL question for you guys but is driving me crazy.

I have two tables: A and B

Example:

Table A has 500 rows that meet certain search criteria.
Table B has 450 rows that meet the same search criteria used for table A.

The tables should return the same number of rows.

Question:

How would I write a query that would return the 50 rows that exist in table A but not in table B?

Thanks in advance for any help!

 
Try this:

Select a.* from A left outer join B
on A.column1 = B.column1
and A.coumn2 = B.column2
where b.Column1 is null

Hope this helps.
 
If you have some sort of common field between the two tables, you can do a left or right outer join to get the rows that don't match.


HTH,

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top