CREATE TABLE `test_id` (
`id` int(11) NOT NULL DEFAULT 0 ,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'XX' ,
PRIMARY KEY (`id`)
)
select count(*),t1.`name` from test_id t1
INNER JOIN test_id t2
on t1.id >= t2.id
group by t1.id,t1.`name`
结果
1 XX1
2 XX2
3 XX3
4 XX5
5 XX7
6 XX9