【发布时间】:2021-02-10 20:23:25
【问题描述】:
表 * 文章包含 6 7 列。
id | Article | Date | Document | In | Out | Status
1 7156 2020-10-26 test 0 14 1
2 7157 2020-10-27 test 2 0 15 1
3 7158 2020-10-28 test 3 0 14 1
4 7156 2020-10-26 test 0 14 1
有没有一种方法可以找到并列出 4 列(文章、文档、in)的所有重复项。
上表的重复行 id 为 4
4 7156 2020-10-26 test 0 14 1
我正在尝试下面的查询,但没有得到好的结果。
select s.id, t.*
from [articles ] s
join (
select Article, Date, Document, Out, count(*) as qty
from [articles]
group by Article, Date, Document, Out
having count(*) > 1
) t on s.Article= t.Article and s.Date= t.Date and s.Document= t.Document and s.Out = t.out
在MYSQL中可以直接通过查询找到吗?
【问题讨论】:
标签: php sql count duplicates subquery