04 Try it yourself Interactive

Watch NOT IN return nothing at all

One question, asked twice against the same four students: who is nobody’s mentor? Reading the table by eye, the answer is Chetan and Divya, because the mentor column holds NULL, S1, S1 and S2, and neither S3 nor S4 appears in it. NOT IN is the obvious way to write that. NOT EXISTS is the way that works. Step through both and watch the verdict for each student. Nothing plays on its own: Next, Back and Reset, or the arrow keys.

NOT IN
nothing has run yet
Left card is the outer row being tested. Middle card is what the subquery produced for it. Right card is the verdict WHERE receives. Indigo marks the card this step is about.
Press Next to begin. Each press tests one more student.


      
Row being tested
Subquery runs0
Rows kept0
UNKNOWN verdicts0
step 0 / 0