Alih-alih mengatur variabel dalam SET
yang terpisah , sudahkah Anda mencoba menggunakan 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";