mysql 断号查询

分类:CentOS运维 阅读:95986 次

select id1,(select min(id)-1 from news where id>id1) as id2 from (select id+1 as id1 from news where id+1 not in (select id from news ) and id <(select max(id) from news )) as cc;

news 是表名称 id 是字段的名称

1 2 3 4 5 19 20 21 自动打印出中间断号的ID