我有这张桌子玩游戏
scores (user,score)
里面有一些条目,我有这个查询:
SET @row_num = 0;
SELECT @row_num := @row_num + 1 as row_index, user, score FROM scores ORDER BY score DESC
它适用于 phpmyadmin 但不适用于 php 代码
$query = "set @row_num = 0; SELECT @row_num := @row_num + 1 as row_index, user, score FROM scores ORDER BY score DESC";
$result = mysql_query($query) or die(mysql_error());
php已正确连接到mysql数据库,在此之前我做了其他查询,一切正常
它说:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT @row_num := @row_num + 1 as row_index, user, score FROM scores ORDER BY s' at line 1
你认为它可能是什么?谢谢你,亚历山德罗