在我的數據庫中的最低值有5個值:50,75,95,125和200。當我查詢的最小值,我得到125,但我應該得到50想從SQL
這裏我的代碼:
$result_upTICKET = mysql_query("SELECT ID, EID, COMMISSION, MIN(PRICE) as PRICE FROM `tickets` WHERE EID='$EID_UPcoMing' AND STATUS='1'");
while($row_upTICKET = mysql_fetch_array($result_upTICKET))
{
$PRICE_upTICKET= $row_upTICKET['PRICE'];
$COMMISSION_upTICKET= $row_upTICKET['COMMISSION'];
}
我得到了什麼問題?
你應該寫你的min()作爲where條件 –
.......極限n:D – DaAmidza
***請[停止使用'mysql_ *'函數](http://stackoverflow.com/questions /12859942/why-shouldnt-i-use-mysql-functions-in-php).*** [這些擴展程序](http://php.net/manual/en/migration70.removed-exts-sapis.php)已在PHP 7中刪除。瞭解[準備](http://en.wikipedia.org/wiki/Prepared_statement)[PDO]的聲明(http://php.net/manual/en/pdo.prepared-statements .php)和[MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)並考慮使用PDO,[這真的很簡單](http://jayblanchard.net/ demystifying_php_pdo.html)。 –