Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如果SQL语法有错误,请查看手册_Mysql_Syntax - Fatal编程技术网

Mysql 如果SQL语法有错误,请查看手册

Mysql 如果SQL语法有错误,请查看手册,mysql,syntax,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服务器版

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行选择@row_num:=@row_num+1作为行数)附近使用的正确语法


您尝试在一个步骤中执行两条语句。使用

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

要将其合并为一个查询。

您使用的是PHP吗?在一个
mysql\u query()
中只能有一个查询,这里有两个(set@row\u num=0是一个查询,选择也可以)