Mysql query not working with DB execute

Permalink
Hi,
I have this mysql query tested on Navicat.
SET @r=0; UPDATE table SET ranking= @r:= (@r+1) WHERE groupid = 1 ORDER BY points DESC"

It works fine. However, when I did the same on my controller using:
$db->Execute("SET @r=0; UPDATE table SET ranking= @r:= (@r+1) WHERE groupid = 1 ORDER BY points DESC");

it shows this error:
An exception occurred while executing 'SET @r=0; UPDATE table SET ranking= @r:= (@r+1) WHERE groupid = 1 ORDER BY points DESC'
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE table......'
Why is that not working?

View Replies: