尝试从数据库中求和一个MAX值

时间:2015-08-20 02:29:55

标签: mysql

我得到未定义的索引:总是知道我做错了什么

$sql = "SELECT SUM(max_score) FROM (SELECT war_enemy, MAX(score) AS max_score FROM score WHERE war_enemy ='$enemy_name' GROUP BY enemy_enemynumber) AS total";
$result = mysqli_query($database,$sql) or die(mysqli_error($database));
while($res = mysqli_fetch_array($result)){      
echo $res['SUM(max_score)'];
echo $res['total'];
}

我尝试删除AS总数并获取每个派生表必须有自己的别名 任何想法都错了

0 个答案:

没有答案