select t.*,( case when (select count(1) from t_xdt_usual_question_type t1 where t1.PARENT_TAG=t.issue_TYPE )>0 then 'true' else 'false' end )
as isparent from t_xdt_usual_question_type t where 1=1;case when 条件1 then 结果1 else 结果2 end的用法
当满足条件的时候,返回结果1,不满足返回结果2
as isparent from t_xdt_usual_question_type t where 1=1;case when 条件1 then 结果1 else 结果2 end的用法
当满足条件的时候,返回结果1,不满足返回结果2
(case
when (select count(1)
from t_xdt_usual_question_type t1
where t1.PARENT_TAG = t.issue_TYPE) > 0 then
'true'
else
'false'
end) as isparent
from t_xdt_usual_question_type t
where 1 = 1;查询表t_xdt_usual_question_type 所有字段以及isparent字段 isparent字段显示有下面查询确定
如果查询select count(1)
from t_xdt_usual_question_type t1
where t1.PARENT_TAG = t.issue_TYPE) > 0 结果大于0 isparent字段显示为true 否则显示为false