简体   繁体   中英

min and max value for a row, not column

In my mysql table on the same row i have a persons name, value1, value2, value3, value4, value5. I want to get the lowest value from values 1-5 and put it in column lowestvalue.

I know how to get minimum and maximum values from a chosen column, as stated in mysql documentation 3.6.1, but i dont know how to get minimum and maximum values from a chosen row. I cant find that in mysql documentation.

Could some one tell me or point me in the right direction. Cheers

SELECT GREATEST(`value1`, `value2`, `value3`, `value4`, `value5`) as `highest`
FROM `tablename` WHERE .....

创建另一个表(名称,值),按名称将其与第一个表链接,并使用标准最小/最大函数

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM