T
T
Timofey2020-06-18 11:26:52
SQL
Timofey, 2020-06-18 11:26:52

How to select a SQL field that has one of the departments NULL?

I am doing a test task, I encountered SQL, I wrote all previous works in c #, I don’t understand how to arrange everything and how it should look5eeb254862818966319291.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2020-06-18
@timofeygusevopal

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;

But it's probably worth learning basic SQL, or will you also send part of the RFP to the toaster at work?

K
Konstantin Tsvetkov, 2020-06-18
@tsklab

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 question

Ask a Question

731 491 924 answers to any question