Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找返回 Sno 和行的 MySQL 查询。请注意,查询使用按功能分组。
请注意下面的查询。它不适用于按功能分组
SELECT @rownum:= @rownum+1 AS Sno FROM tableName, (SELECT @rownum:=0) r;
有人可以解释为什么我r在上面查询的末尾没有出现错误吗?
r
(SELECT @rownum:=0)是派生表,必须在 MySQL 中为其指定别名,否则将引发错误。尝试这个:
(SELECT @rownum:=0)
SET @rownum = 0; SELECT (@rownum:= @rownum + 1) AS Sno FROM tableName;