Reputation: 9853
I am trying to do the following but I dont have enough experience with MySQL. Would it be possible for someone to tell me what the query for this will be.
I have a databse with 2 tables
Brief
and Info
have various fields but I am interested in only ID
field.
This is what I am trying to do.
I want to go through all the IDs from Brief and cross reference them with all the IDs that exists in Info and only get the ones that exist in Info but dont exist in Brief
Thanks
Upvotes: 3
Views: 49
Reputation: 3606
SELECT * from info i LEFT JOIN brief b ON b.id=i.id WHERE b.id IS NULL
Upvotes: 1
Reputation: 30111
SELECT i.ID
FROM Info i
LEFT JOIN Brief b USING(ID)
WHERE b.ID IS NULL
Alternatively:
SELECT i.ID
FROM Info i
WHERE NOT EXISTS (
SELECT 1
FROM Brief b
WHERE b.ID = i.ID
)
See these 2 links for performance comparisons:
Upvotes: 4