I have this query:
$query = "
SET @points := -1;
SET @num := 0;
SELECT `id`,`rank`,
@num := if(@points = `rank`, @num, @num + 1) as `point_rank`
FROM `said`
ORDER BY `rank` *1 desc, `id` asc";
I am using this request from php; giving me this error:
You have an error in the SQL syntax; check the manual that matches your version of MySQL server for the correct syntax to use next to 'SET @num: = 0;
If I copy and paste this code into the phpmyadmin Sql query panel, it works fine, but from the php code lines it doesn't work, it seems that there are problems setting up Vars.
source
share