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 に答える