答案 0 :(得分:0)
您可以使用mySQL SELECT MAX(your_average_col)
中的内置内容 - > MySQL doc
$query = " SELECT col1, col2, MAX(colAVG) AS maxAVG FROM my_table ";
$stmt1 = $mysqli->prepare($query);
$results = $stmt1->execute();
$stmt1->bind_result($col1, $col2, $maxAVG);
$stmt1->store_result();
if ($stmt1->num_rows > 0) {
while($stmt1->fetch()){
echo"[ $col1 -> $col2 -> $maxAVG ]<br />";
}
}
else
{ echo"[ no data ]"; }
重要:即使接受了答案,我认为使用反引号来保护列名可能很有用,因为它们的名称中包含()。