查询出结果 给其 加上序号的方法 msql

基本用法

SELECT
@rownum := @rownum +1 AS rownum,
e.*
FROM
(SELECT
@rownum := 0) r ,
(select A.id,B.user_uuid, A.mobile1 ,count( B.user_uuid) FROM user A , c_user_custom B WHERE A.uuid = B.user_uuid Group By user_uuid ORDER BY count( B.user_uuid) )e ;

黄色字段是放入你已经查询好的数据,然后查出来的结果 就会在你查出来的数据前面加一个序列

效果:

原文地址:https://www.cnblogs.com/kaibindirver/p/10031344.html