mysql查询不连续id

  sre
select id from (select id from testtable order by id asc) t where not exists (select 1 from testtable where id=t.id-1)

mysql的in和exists

in适合于外表大而内表小的情况,exists适合于外表小而内表大的情况。

LEAVE A COMMENT

Captcha Code