用mysql的 sql 语句 找出 id 最后面100条 里 不连续的 最开始的id

lilinew 2010-03-28 09:02:12
我做了一个主机 从机器 复制系统 (在线数据 表级别复制)
有时候发现从机器发生错误
用change master 之后 salve start 是成功的

这个时候发现从机器很多表都丢失了部分数据 ,好在不多 ,也就1-5条,
现在发现很有规律 ,从机器都是从id不连续的地方掉的数据。

如果用mysql的 sql 语句 找出 id 最后面100条
里 不连续的 最开始的id ??
...全文
226 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lilinew 2010-03-29
  • 打赏
  • 举报
回复
strong . admire
懒得去死 2010-03-29
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 acmain_chm 的回复:]

SQL code
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)
[/Quote]


兄弟SQL 高手!
sjzzy 2010-03-29
  • 打赏
  • 举报
回复
学习之~~
jlnuboy 2010-03-29
  • 打赏
  • 举报
回复
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
lilinew 2010-03-29
  • 打赏
  • 举报
回复
(select 1 from 能够解释一下为什么能这样使用
这种表达方式有什么规律??
ACMAIN_CHM 2010-03-28
  • 打赏
  • 举报
回复
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)

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧