sql中case when then else 用法

£神魔★判官ぃ 2023-10-05 18:12 112阅读 0赞
  1. <if test="c.type==3 and c.type!=null and c.type!=''">
  2. ORDER BY (
  3. case
  4. when socialSecurity=0 then 3
  5. when socialSecurity>=1 then 2
  6. when socialSecurity =-1 then 1
  7. else '0'
  8. end
  9. )DESC
  10. </if>

case when socialSecurity=0 then 3 else ‘0’ end from
类似于三元运算符
socialSecurity=0 ?3:‘0’
或者:
if( socialSecurity=0){
socialSecurity=3
}else{
socialSecurity=‘0’
}

发表评论

表情:
评论列表 (有 0 条评论,112人围观)

还没有评论,来说两句吧...

相关阅读