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 开发者_JAVA技巧LIMIT " . ($page-1)*$Limit . ",$Limit");
Any ideas?
You are missing the AS
clause:
MIN(online_price) AS minprice
You now have the result in minprice
.
Perhaps:
MIN(IF(online_price=0,NULL,online_price))
精彩评论