桌子 :
========================================
|id| document_id | sentence_id | score |
========================================
|1 | 3 | 1 | 0.324 |
|2 | 3 | 2 | 0.201 |
|3 | 5 | 1 | 0.181 |
|4 | 5 | 2 | 0.402 |
========================================
我想在每个中获得最高分,document_id
然后将结果与其他结果进行比较document_id
。我的目标是获得序列document_id. so from the example, the result must be 5 3
$q = mysql_query("SELECT document_id, MAX(score) as max_score FROM `tb_score` GROUP BY document_id ");
while ($row = mysql_fetch_array($q)) {
$min = $row['max_score'];
}
我仍然得到错误的结果。请帮我。