select count(*),t1.`name` from test_id t1INNER JOIN test_id t2on t1.id >= t2.idgroup by t1.id,t1.`name`HAVING count(*) < t1.idorder by t1.idlimit 1;select * from test_id;
表结构看上一篇