Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Yes, I misunderstood the question.
This is who is without a boss:
WHERE chief IS NULL
This is who is not a boss:
SELECT * FROM table AS s WHERE (SELECT chief FROM table AS p WHERE p.chief = s.Id LIMIT 1) IS NULL;
SELECT * FROM Person
WHERE NOT EXISTS (SELECT * FROM Person AS PersonChief WHERE PersonChief.chief = Person.Id)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question