H伙计们
我只需要一个选择查询,它将返回新的位置列,即
我希望结果是
id score position
23 345 1
09 309 2
12 123 3
我尝试了这个但是没有用
(SELECT @rownum := @rownum + 1 AS position,
id,
score
FROM tabs
ORDER BY score DESC");
位置行为空,请帮助使用php
答案 0 :(得分:1)
SELECT @rownum := @rownum + 1 AS position,
id,
score
FROM tabs, (SELECT @rownum:=0) AS initrownum
ORDER BY score DESC
答案 1 :(得分:0)
您的查询应该是:SELECT id, score FROM tabs ORDER BY score DESC
和您的php:
for($i = 0; $i < sizeof($result); $i++){
echo $i;
echo $result['id'][$i];
echo $result['score'][$i]
//br the line here
}