Mysql Variables not working through php mysql query -


i have query:

$query = "    set @points := -1;  set @num := 0;   select `id`,`rank`,  @num := if(@points = `rank`, @num, @num + 1) `point_rank`  `said`  order `rank` *1 desc, `id` asc"; 

i'm using query php; giving me error:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'set @num := 0;

if copy , paste code in phpmyadmin sql query panel, works perfectly, php code lines it's not working, seems there's issues while setting vars.

instead of setting variables in separate set, have tried using cross join:

$query = "   select `id`,   `rank`,   @num := if(@points = `rank`, @num, @num + 1) `point_rank` `said` cross join (select @points:=-1, @num:=0) c order `rank` *1 desc, `id` asc"; 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -