My table is:
Tree table:
+----+------+
| id | p_id |
+----+------+
| 1  | null |
| 2  | 1    |
| 3  | 1    |
| 4  | 2    |
| 5  | 2    |
+----+------+
If I execute
SELECT id FROM Tree
WHERE id IN (SELECT p_id FROM Tree)
I get the expected answer
+----+
| id | 
+----+
| 1  | 
| 2  | 
+----+
However, if I execute
SELECT id FROM Tree
WHERE id NOT IN (SELECT p_id FROM Tree)
I get an empty result:
+----+
| id | 
+----+ 
+----+
instead of the expected 3, 4, 5. As far as I understand, NOT IN should give the complementary set given by IN (excluding NULLs)?
New to SQL, sorry if I'm missing something basic.
 
     
     
    