我有一个包含多列的 MYSQL 表:
col1 | col2 | col3 | col4 | col5 | col6 | min_all_col |
25 | 27 | 35 | 21 | 37 | 34 | |
我需要知道如何用最小值更新列 (min_all_cols) 所有 6 列,例如 21 我尝试了几个 UPDATE 语句,但似乎让自己感到困惑。
谁能帮帮我? 问候
最佳答案
使用LEAST :
LEAST(value1,value2,...)
With two or more arguments, returns the smallest (minimum-valued) argument.
UPDATE tableName
SET min_all_col = LEAST(col1,col2,col3,col4,col5,col6);
关于PHP-用多列的最小值更新一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20543106/