这可能是一个可以在一行中回答的问题,但实际上我在两个小时内找不到它。
<?php
$con = mysql_connect("localhost","root",'');
if(!$con){
die('could not connect'.mysql_error());
}
@mysql_select_db("uni",$con) or die("Unable to select db");
$query = "SELECT MAX(grade) AS HighestPrice from grades";
$res = mysql_query($query);
if(!$res){
echo mysql_error();
exit;
}
else{
while($row = mysql_fetch_assoc($res)) {
echo "The max num is ". $row['HighestPrice']."this is it";
}
}
我希望它返回的是使用max命令的成绩表的最大值。只需提及,我确实想使整个sql命令也需要具有min,因此如果可能的话也要加上它,将不胜感激。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句