The first few days of encountering a requirement is to take the maximum value out of the three columns,
Thought for a long time did not think out.
So I checked the next.
MySQL provides both greatest and LEAST with N parameters, and returns the maximum and minimum values, respectively.
The following description GREATEST and LEAST syntax of the function:
Greatest (Value1, value2, ...); LEAST (Value1,value2,...);
Parameters may have mixed data types. The following comparison rules apply to these two functions:
- If any parameter is NULL, then two functions are returned immediately
NULL without any comparison.
- If you use a function in an int or
REAL context, or if all parameters are integer values or REAL values, they are compared as INT and REAL to each.
- If the argument consists of a number and a string, the function compares them as numbers.
- If at least one parameter is a non-binary (character) string, the function compares the argument as a non-binary string.
- In all other cases, the function compares the arguments as a binary string
MySQL Greatest function