1

我正在尝试选择数据库中所有重复的行。我有下表:

title     content
aa          hahaha
bb          weeeee
cc          dddddd
aa          ggggg
aa          ggggggee
dd          hhhhhhh
bb          ggggggg

我的查询是

select count(post_title) as total, content from post group by post_title

它只会显示

 total        content
    3        hahaha
    2        weeeeee

但我想展示类似的东西

total        content
aa          hahaha
aa          ggggg
aa          ggggggee
bb          weeeeeee
bb          geeeeeee

不知道该怎么做,我认为这可能很简单。谢谢您的帮助。

4

3 回答 3

6
Select title, content
From table_name
Where title In
    (Select title From Table
     Group By title
     Having COUNT(*) > 1)

(来自Multiple NOT distinct

于 2012-07-08T15:22:12.763 回答
0

据我了解,SQL 查询应如下所示:

SELECT post_title, content
FROM post
GROUP BY post_title, content
于 2012-07-08T15:20:29.363 回答
0

尝试类似的东西

SELECT total, content FROM post 
   WHERE id IN ( 
    SELECT id FROM post 
         GROUP BY post_title 
         HAVING count(post_title) > 1 
   )
于 2012-07-08T15:21:59.410 回答