您的SQL语法有错误,请查看手册

时间:2013-11-10 15:15:20

标签: mysql syntax

MySQL查询:

set @row_num = 0; SELECT profile, row_number as rank FROM(SELECT @row_num := @row_num + 1 as row_number, time, profile, map FROM records WHERE map='". $map ."' ORDER BY time) as t WHERE profile='". $profile ."'

错误:

  

您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在'SELECT profile,row_number作为排名FROM附近使用正确的语法(SELECT @row_num:= @row_num + 1作为row_nu'在第1行

1 个答案:

答案 0 :(得分:0)

您尝试一步执行2个语句。使用

SELECT profile, row_number as rank 
FROM
(
  SELECT @row_num := @row_num + 1 as row_number, time, profile, map 
  FROM records, (select @row_num := 0) r
  WHERE map='". $map ."' 
  ORDER BY time
) as t
WHERE profile='". $profile ."'

将其合并为一个。