[转]MySQL 行号

本文转自:http://xi5566.javaeye.com/blog/204753

select *,(select count(*)+1 from table where table.userId<a.userId )as rowId from table as a
注意这里的userId一定要是自增长

原文地址:https://www.cnblogs.com/freeliver54/p/1360834.html