1、第一种写法
select id,
case
when p_id is null then "Root"
when id not in (select distinct p_id from Tree where p_id is not null) then "Leaf"
else "Inner"
end as type // 为该列起别名
from Tree
2、第二种写法(case后面有表达式;值1、值2等为固定值)
3、第三种写法
标签:语句,case,逻辑,when,Mysql,null,写法,id,select From: https://www.cnblogs.com/ReturnOfTheKing/p/17807594.html