1

I am trying to select all the duplicated row in my database. I have table below:

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

my query is

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

it will only show

 total        content
    3        hahaha
    2        weeeeee

but i want to show something like

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

not sure what to do and I think it might be simple. Thanks for the help.

FlyingCat
  • 14,036
  • 36
  • 119
  • 198

3 Answers3

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

(from Multiple NOT distinct)

Community
  • 1
  • 1
chrisbulmer
  • 1,237
  • 8
  • 15
0

From what I understand, the SQL query should look like:

SELECT post_title, content
FROM post
GROUP BY post_title, content
Simon Forsberg
  • 13,086
  • 10
  • 64
  • 108
0

try with something like

SELECT total, content FROM post 
   WHERE id IN ( 
    SELECT id FROM post 
         GROUP BY post_title 
         HAVING count(post_title) > 1 
   )
Tudor Constantin
  • 26,330
  • 7
  • 49
  • 72