SQL条件控制(case when...then...when……then……else...end)

Case  When Condition Condition 1 then 2 then the value 1 when the value 2   the else  Value. 3  End

After the then (can, but to be consistent numeric or string type and so on) when the field value is then conditional statements.

1. Simple case function  
case sex  when '1' then '男'  when '2' then '女’  else '其他' end  
2.case search functions 

case when sex = '1' then ' M' 8 when sex = '2' then ' F' 9 else 'other' end

Guess you like

Origin www.cnblogs.com/yaoze2018/p/11318220.html