我有这张桌子:
fistname | lastname | english
---------------------------------------------
bob | wilson | 77
jess | farr | 47
这是我用php编写的代码:
$con = mysql_connect('localhost','root','');
mysql_select_db('education');
$highest= mysql_query("SELECT firstname, lastname, max(english)FROM students");
$row = mysql_fetch_row($highest);
echo 'English Highscore:' ;
echo "\r\n" ;
echo $row[0];
echo ' ';
echo $row[1];
它将显示杰西是得分最高的,而不是鲍勃:
最佳答案
试试这个:
$highest= mysql_query("SELECT firstname, lastname, english FROM students order by english DESC limit 1");
关于php - MAX功能不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22270615/