mysql 行号查询

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

1

SET @row_number = 0;
 
SELECT 
    (@row_number:=@row_number + 1) AS num, firstName, lastName
FROM
    employees
LIMIT 5;

2

SELECT 
    (@row_number:=@row_number + 1) AS num, firstName, lastName
FROM
    employees,(SELECT @row_number:=0) AS t
LIMIT 5;

转载于:https://my.oschina.net/u/3238650/blog/3023312

你可能感兴趣的:(mysql 行号查询)