SQL过滤掉一些数据?

时间:2022-02-05 07:13:47

I have a database table: mydata

我有一个数据库表:mydata

id    content   name
1     1         a
2     2         b
3     2         c
4     13        hhh
5     13        yyyy
6     7         wwww
7     13        iiii
8     7         nnnn
9     8         oooo

It will look at "content" field. If the same value inside "content" show up more than one time, it will display out. Here is final result

它将查看“内容”字段。如果“内容”中的相同值出现多次,则会显示出来。这是最终结果

id    content   name
2     2         b
3     2         c
6     7         wwww
8     7         nnnn
4     13        hhh
5     13        yyyy
7     13        iiii

Thus how to write this SQL?

那么如何编写这个SQL呢?

1 个解决方案

#1


3  

select *
from myData
where content in (
  select content
  from myData
  group by content
  having count(*) > 1)

#1


3  

select *
from myData
where content in (
  select content
  from myData
  group by content
  having count(*) > 1)