What will be the result of the query below

Given the following tables:

sql> SELECT * FROM runners;

+----+--------------+
  id | name         |
+----+--------------+
   1 | John Doe     |
   2 | Jane Doe     |
   3 | Alice Jones  |
   4 | Bobby Louis  |
   5 | Lisa Romero  |
+----+--------------+

sql> SELECT * FROM races;

+----+----------------+-----------+
  id | event          | winner_id |
+----+----------------+-----------+
   1 | 100 meter dash |  2        |
   2 | 500 meter dash |  3        |
   3 | cross-country  |  2        |
   4 | triathalon     |  NULL     |
+----+----------------+-----------+

What will be the result of the query below?

SELECT * FROM runners 
WHERE id NOT IN (SELECT winner_id FROM races)

This will return empty set because NOT IN condition contains any values that are null, then the outer query here will return an empty set.

SELECT * FROM runners 
WHERE id NOT IN 
(SELECT winner_id FROM races WHERE winner_id IS NOT null)

results matching ""

    No results matching ""