使用 mysql min() 查找下一个最小值
我有一个脚本来查找列中的最低值,但某些条目没有值或将其设置为 0(如果是这种情况)我希望 ti 找到下一个最低值。
这是我的sql命令。
$result = mysql_query("SELECT DISTINCT product_name, format, image_url, MIN(online_price), EAN FROM products where $searchstring and format = '{$cat}' AND EAN != ' ' AND EAN != '-' AND EAN != 'PRERELEASE' AND online_price > '0' group by EAN LIMIT " . ($page-1)*$Limit . ",$Limit");
有什么想法吗?
I have a script to find the lowest value from a column but some entries dont have a value or its set to 0 if this is the case I'd like ti to find the next lowest value.
Here is my sql command.
$result = mysql_query("SELECT DISTINCT product_name, format, image_url, MIN(online_price), EAN FROM products where $searchstring and format = '{$cat}' AND EAN != ' ' AND EAN != '-' AND EAN != 'PRERELEASE' AND online_price > '0' group by EAN LIMIT " . ($page-1)*$Limit . ",$Limit");
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您缺少
AS
子句:您现在在
minprice
中得到结果。You are missing the
AS
clause:You now have the result in
minprice
.也许:
Perhaps: