MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Jeff Gannaway Date:July 10 2004 4:03pm
Subject:Finding the records in one table that are not in another table
View as plain text  
I have 2 tables - ProductsOLD and ProductsNEW.  I need to find the records 
that are in the ProductsOLD table and are NOT in ProductsNEW (this will 
tell me which products have been discontinued).

Here's some sample data:
+==============+
| ProductsOLD  |
+==============+
+ Vendor | ID  |
+--------+-----+
| AAD    | 1   |
| AAD    | 2   |
| AAD    | 3   |*
| BBD    | 1   |*
| BBD    | 2   |
| BBD    | 3   |*
+--------+-----+
(* = these are the products that are NOT in the ProductsNEW table)


+==============+
| ProductsNEW  |
+==============+
+ Vendor | ID  |
+--------+-----+
| AAD    | 1   |
| AAD    | 2   |
| AAD    | 5   |
| BBD    | 2   |
| BBD    | 7   |
| BBD    | 10  |
+--------+-----+

I need to know the query that would result in:

+==============+
+ Vendor | ID  |
+--------+-----+
| AAD    | 3   |
| BBD    | 1   |
| BBD    | 3   |
+--------+-----+

There is no primary key for either ProductsNEW or ProductsOLD.  The data 
comes from our distributor, and they don't have any field which would be 
unique from record to record.  If a primary key is essential, I can 
pre-process the tables to create one.

Thanks in advance for your help!!!
-Jeff Gannaway
_______________________________________________

http://RadioU.com
This Is Where Music Is Going - Listen Online!
_______________________________________________


Thread
Finding the records in one table that are not in another tableJeff Gannaway10 Jul
  • Re: Finding the records in one table that are not in another tableRory McKinley10 Jul
  • Re: Finding the records in one table that are not in anothertablemos10 Jul