我做了一个主机 从机器 复制系统 (在线数据   表级别复制)
有时候发现从机器发生错误 
用change master 之后 salve start 是成功的 这个时候发现从机器很多表都丢失了部分数据 ,好在不多 ,也就1-5条,
现在发现很有规律 ,从机器都是从id不连续的地方掉的数据。如果用mysql的 sql 语句 找出  id 最后面100条
里 不连续的 最开始的id  ??

解决方案 »

  1.   

    select *
    from (select id from xxx order by id desc limit 100) t
    where not exists (select 1 from xxx where id=t.id-1)
      

  2.   

    (select 1 from  能够解释一下为什么能这样使用
    这种表达方式有什么规律??
      

  3.   

    select  * from (select id from xxx where id > ? order by id desc limit 100) t left join 
    (select id-1 as id from xxx where id > ? order by id desc limit 100) p on t.id = p.id
    where p.id is null