jamesTheProgrammer
jamesTheProgrammer

Reputation: 1777

How do I get the records from the left side of a join that do not exist in the joined table?

I have table a joining table b, I only want the records from table a that do not exist in table b.

My partial query is:

SELECT DISTINCT u.id, u.lastname
FROM user u
LEFT JOIN context ct
ON ct.userid = u.id

thank you.

Upvotes: 0

Views: 146

Answers (1)

D'Arcy Rittich
D'Arcy Rittich

Reputation: 171411

select distinct u.id,
    u.lastname
from user u
left join context ct on ct.userid = u.id
where ct.userid is null

Upvotes: 3

Related Questions