MYSQL Query Maximum in Three Columns

  ios, question

For example, mysql has the following data structure

数据库结构

At present, there is already one sql to query the maximum value in the three columns of AB C. Would you like to ask if there are any other better idea? ..

Select id,a,b,c,(a plus ((b plus c plus abs(b-c))/2) plus abs(a-(b plus c plus abs (b-c))/2) from test;

I learned another lesson from others this afternoon.greatestFunction

select id,a,b,c,greatest(a,b,c) as max from XXX
mysql> set @a = 5, @b = 6, @c = 11;
 Query OK, 0 rows affected (0.00 sec)
 
 mysql> select if(@a > @b, if(@a > @c, @a, @c), if(@b > @c, @b, @c)) max;
 Plus-plus
 | max  |
 Plus-plus
 |   11 |
 Plus-plus
 1 row in set (0.00 sec)