I have 2 tables:
A table:
---+----------
id + key
B table:
-----+--------+---------
id + value + key
"key" field in B is getting from A table.
I need all id from A table with a 'key' which are absent in B table.
I have 2 tables:
A table:
---+----------
id + key
B table:
-----+--------+---------
id + value + key
"key" field in B is getting from A table.
I need all id from A table with a 'key' which are absent in B table.
Try this:
SELECT id FROM tablea a
WHERE NOT EXISTS (SELECT 1 FROM tableb b WHERE b.key = a.key)
Did you try to use JOIN? If I understood well, you want a full outer join (with exclusion), which is the same as a double "not in".
See picture below for more details.
What about a LEFT JOIN like
select a.id,a.key from A a
left join B b on a.key = b.key
where b.id is null