Mysql-ifnull,if语句

2015-12-17 diaba Mysql

取某行数据多个数值字段最大的一个值

select 
if(field1>field2,field1,field2) as bigger,
if(if(field1>field2,field1,field2)>if(field3>field4,field3,field4),if(field1>field2,field1,field2),if(field3>field4,field3,field4)) as biggest 
from dual;

标签: mysql if ifnull

发表评论:

Powered by emlog 京ICP备15045175号-1 Copyright © 2022