Reputation: 351
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
Upvotes: 0
Views: 281
Reputation: 86
Create another table (name, value), link it with first table by name and use standart min/max functions
Upvotes: 1
Reputation: 324840
SELECT GREATEST(`value1`, `value2`, `value3`, `value4`, `value5`) as `highest`
FROM `tablename` WHERE .....
Upvotes: 2