我有一个使用 MySQL 会话变量的查询(注意 @rank 变量)
SELECT Rank, UserId, CurrentVDOT
FROM
(
SELECT @rank := @rank + 1 AS Rank, UserId, MaxVDOT AS CurrentVDOT
FROM
(
SELECT UserId, MAX(VDOT) AS MaxVDOT
FROM
(
SELECT U.UserId, U.VDOT
FROM
(
SELECT UserId, MAX(Created) AS Created
FROM UserVDOT
GROUP BY UserId
) G
INNER JOIN UserVDOT U
ON U.UserId = G.UserId
AND U.Created = G.Created
) M
GROUP BY UserId
ORDER BY MaxVDOT DESC
) R, (SELECT @rank := 0) foo
) F
WHERE F.UserId = @UserId;
如果我尝试针对 C# MySQL 连接器执行此操作,它会尝试告诉我需要将 @rank 声明为输入参数变量。
有没有办法解决?
谢谢。