mysql流程控制语句

58 阅读1分钟

1、if函数  if else效果

select if(10>5,'大''小'

2、case函数的使用    switch case 效果

case  要判断的字段或者表达式
when  常量1  then  要显示的值1或语句1
when  常量1  then   要显示的值2或语句2
else  要显示的值n或语句n;
end
case
when 条件1  then 要显示的值1或者语句1
when 条件2  then 要显示的值2或者语句2
...
else 要显示的值n或者语句n
end