mysql从多选中选择最低价格 [英] mysql select lowest price from multi select

查看:52
本文介绍了mysql从多选中选择最低价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

表价格

user_id    b01    b02    b03    b04    b05    b06    b07    b08    b09
MP01       21     32     12     34     56     26     21     21     26    
MO11       81     332    112    1      12     22     71     17     23  

如何从WHERE user_id ='MP01'的价格中选择最低价格?

How to SELECT lowest price FROM price WHERE user_id = 'MP01' ?

user_id MP01的示例,获取结果12

example for user_id MP01, to get the result 12

推荐答案

您可以使用LEAST函数,如下所示:

you can use the LEAST function, as in:

select least(b01,b02,b03,b04,b05,b06,b07,b08,b09) from price where user_id = 'MP01'

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_least

这篇关于mysql从多选中选择最低价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆