I stedet for at indstille variablerne i et separat SET
, har du prøvet at bruge en 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";