SELECT
s.*,
@ROW := @ROW + 1 AS row_num
FROM
( SELECT s.name FROM emp s WHERE s.dept_a = 'xxx' GROUP BY s.dept ) s,(
SELECT
@ROW := 0
) t
【MySQL】MySQL如何查询获取行号rownum
最新推荐文章于 2024-07-29 11:25:31 发布
SELECT
s.*,
@ROW := @ROW + 1 AS row_num
FROM
( SELECT s.name FROM emp s WHERE s.dept_a = 'xxx' GROUP BY s.dept ) s,(
SELECT
@ROW := 0
) t