How to get records that exist in one MySql table and not another
I need to write a query that returns the records that exist in one MySql
table and do not exist in the other table. In this example, I want all of
the wafers that exist in the wafer_log table that do not exist in the
bt_log table.
Here is the current query I'm using:
SELECT wafer_log.wafer, bt_log.id AS blid, wafer_log.id AS wlid
FROM bt_log RIGHT OUTER JOIN wafer_log
ON bt_log.waferid = wafer_log.wafer
WHERE wafer_log.wafer IS NOT NULL AND bt_log.id NULL;
My thought here was to get the wafer name from the table I care about as
well as the ids for both of the tables and do an outer join on the wafer
name. From there, I wanted to see all of the results where wafer name was
not null in wafer_log table and id in the bt_log is null.
I don't feel like the results look right though.
Any help would be appreciated.
No comments:
Post a Comment