-1

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 服务器版本相对应的手册,以在第 1 行的 'SELECT profile, row_number as rank FROM(SELECT @row_num := @row_num + 1 as row_nu' 附近使用正确的语法

4

1 回答 1

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 ."'

把它合二为一。

于 2013-11-10T15:21:41.787 回答