When there is a null
in a column, we can't use not in
in a clause. We can only use in
.
# Write your MySQL query statement below
select id,
case
when p_id is null then 'Root'
when id not in (
select p_id from Tree
) then 'Leaf'
else 'Inner'
end type
from Tree
All results supposed to be Leaf
are Inner
now.
# Write your MySQL query statement below
select id,
case
when p_id is null then 'Root'
when id in (
select p_id from Tree
) then 'Inner'
else 'Leaf'
end type
from Tree