我最近一直在将网站迁移到VPS。
这样做,在XAMPP上运行的查询不再在Linux方面运行。
查询的前2个部分运行良好,因此我可以看到问题是由于我感觉到的WITH子句。
此数据库中的表在sql中保存在 https://www.db-fiddle.com/f/718QhKmgPYALAS4Zg94cPx/0
我已经在XAMPP mysql上对此进行了测试,并且可以正常工作。
但是它在Linux上不起作用。
我正在运行的查询是
SET @DrawID := 3;
SELECT 120 into @MaxTicketNo FROM draw WHERE ID = @DrawID;
WITH RECURSIVE TicketNumbers (n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM TicketNumbers WHERE n < @MaxTicketNo) SELECT n FROM TicketNumbers WHERE n NOT IN (SELECT TicketNumber FROM transaction WHERE DrawID = @DrawID) ORDER BY RAND() LIMIT 1;
我在执行查询时收到了此回复
WITH RECURSIVE TicketNumbers (n) AS (SELECT 1 UNION ALL SELECT n + 1 FROM TicketNumbers WHERE n < @MaxTicketNo)
SELECT n FROM TicketNumbers WHERE n NOT IN (SELECT TicketNumber FROM transaction WHERE DrawID = @DrawID)
ORDER BY RAND() LIMIT 1;
错误1064(42000):您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册以获取正确的语法,以在“ RECURSIVE TicketNumbers(n)AS”(第1行的“ SELECT 1 UNION ALL SELECT n + 1 FROM TicketNumbe”)附近使用 “