mysql 用if 语句

版权声明:廖圣平博客,未经博主允许不得转载。企鹅:1194008361 https://blog.csdn.net/qq_22823581/article/details/86088372

方法一

亲测:

where 
if(type =5,order_type=1,order_type=2)

方法二

用 case when then 代替,else if

CASE type WHEN 5 THEN
order_id =1
WHEN 3 THEN
order_id =2
END

表达:如果type=5 order_type等于1,否则等于2

猜你喜欢

转载自blog.csdn.net/qq_22823581/article/details/86088372