Mysql中if语句

版权声明:如若转载,请联系作者。 https://blog.csdn.net/liu16659/article/details/82629103

Mysql中的if语句

1.语法

if(expr,a,b):如果expr为真,则取a,否则取b

2.实例

mysql> select if(2>1,3,4);
+-------------+
| if(2>1,3,4) |
+-------------+
|           3 |
+-------------+
1 row in set (0.00 sec)

mysql> select if(2<1,3,4);
+-------------+
| if(2<1,3,4) |
+-------------+
|           4 |
+-------------+
1 row in set (0.00 sec)

猜你喜欢

转载自blog.csdn.net/liu16659/article/details/82629103