- 查询id不连续的位置
select id from (select id from table order by id asc) t where not exists (select 1 from table where id=t.id-1)
#筛选出当前记录存在,但是前一条记录不存在的id
&&
select Id+1 from ntf_sms_black_list a where not exists(select * from ntf_sms_black_list b where b.Id = a.Id + 1) and Id < (select MAX(Id) from ntf_sms_black_list)
#筛选出不连续的缺失id(当前记录存在,下一条记录不存在)
网友评论