I have written a query to get a code from table A which is not in table B for same ID. I have hardcoded the ID in the query, I want to know how to get the desired output for all the IDs not for 539 alone. Below is the query
SELECT
a.code
FROM
A
WHERE
a.code NOT IN(
SELECT
b.code
FROM
B b
WHERE
b.ID='539'
AND b.status <> 'D')
AND
(a.id='539')
AND
(a.status <> 'D')
Join the tables together with a LEFT join and then only select records that do not have a corresponding record in table B