別のSET
で変数を設定する代わりに 、CROSS JOIN
を使用してみましたか :
$query = "
SELECT `id`,
`rank`,
@num := if(@points = `rank`, @num, @num + 1) as `point_rank`
FROM `said`
CROSS JOIN (SELECT @points:=-1, @num:=0) c
ORDER BY `rank` *1 desc, `id` asc";
別のSET
で変数を設定する代わりに 、CROSS JOIN
を使用してみましたか :
$query = "
SELECT `id`,
`rank`,
@num := if(@points = `rank`, @num, @num + 1) as `point_rank`
FROM `said`
CROSS JOIN (SELECT @points:=-1, @num:=0) c
ORDER BY `rank` *1 desc, `id` asc";