原文:https://blog.csdn.net/Beyond737/article/details/109400582
1 SET @rowNum = 0; 2 SELECT 3 ( @rowNum := @rowNum + 1 ) AS rowNo, 4 t.phone, 5 t.count 6 FROM 7 ( SELECT phone, count( 1 ) AS count FROM sign_in GROUP BY phone ORDER BY count DESC LIMIT 10 ) t;
方法一:合并成一条语句
1 SELECT 2 ( @rowNum := @rowNum + 1 ) AS rowNo, 3 t.phone, 4 t.count 5 FROM 6 (SELECT @rowNum := 0) tmp, 7 ( SELECT phone, count( 1 ) AS count FROM sign_in GROUP BY phone ORDER BY count DESC LIMIT 10 ) t;
方法二:mysql数据源url配置追加
&allowMultiQueries=true