Reputation: 9
I am having two tables called abc
and xyz
. The table xyz
contains column id and xyz
contains abc_id
.
I want to find record present in first table but not present in second table. How can I do this.
Upvotes: 0
Views: 71
Reputation: 224
If you want to fetch records from abc table which not in xyz table;
SELECT abc_id FROM abc
WHERE abc_id NOT IN (SELECT id from xyz)
Upvotes: 2
Reputation: 18569
You can use IN as @m.hasan answer or use EXISTS
> Select id from xyz where not exists ( Select abc_id from abc where
> abc_id = xyz.id)
Upvotes: 0
Reputation: 28751
Select id from xyz
where id not in ( Select abc_id from abc)
See more details about NOT IN()
comparison function here
Upvotes: 1