查询:
select
(@rownum:= @rownum + 1) as row_number
from
(select * from information_schema.tables limit 25) t,
(select @rownum := (date_format('2018-12-16 00:00:00','%k'))) r;
在MySQL 8中获得语法错误,但在MySQL 5.7中未获得语法错误。
请帮助。
答案 0 :(得分:1)
杰出的SO人士已经评论过:自mysql 8.0版以来,row_number已成为语言关键字,您不能将其用作列别名。
所以您需要更改此内容:
select
(@rownum:= @rownum + 1) as row_number from
...
收件人:
select (@rownum:= @rownum + 1) as rn from
....
另一种解决方案是引用限定符,例如:
select (@rownum:= @rownum + 1) as "row_number" from
....