我正在尝试执行一个非常长的 SQL 语句,该语句使用多个用户选项选择“前 N”行。我不想在这里发布整个语句,因为它很长,但我正在使用本文所述的 MySQL 变量:MySql Query: Select top 3 rows from table for each category
该语句在 MySQL 命令行上运行时运行良好,但我遇到的问题是整个查询必须通过 PDO 连接运行,我想知道是否有人可以确认我不能将值“即时”设置为如下图所示。这是 PDO 限制吗?我只是浪费了几个小时吗?非常感谢您的帮助 ...
SELECT outerseasons.* FROM (SELECT seasons.CountryName, seasons.idCountry, '' as idCountryGroup, '' as CGName, seasons.DIValue_WorkingEntered,
seasons.SNName, seasons.idSeason, seasons.idParameter, seasons.PMName,
CASE
WHEN @idSeason != seasons.idSeason OR @idParameter != seasons.idParameter
THEN @rownum := 1
ELSE @rownum := @rownum + 1
END AS rank,
@idSeason := seasons.idSeason as var_season,
@idParameter := seasons.idParameter as var_parameter
FROM ( SELECT ...