MYSQL重复具有不同id和created_at列

时间:2018-05-15 11:57:40

标签: mysql

我想从表中找到重复的行,除了id和created_at列之外,所有列都是相同的。 行的条件是

 1. rows are consecutive i-e id always differ by 1 
 2. created at column can differ maximum by 10s.

有没有办法编写mysql查询来查找这些行?

1 个答案:

答案 0 :(得分:0)

SELECT * FROM table a 
WHERE id= (SELECT MAX(id) 
           FROM table b 
           WHERE a.created_at=b.created_at)