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.

3 Answers 3

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

(from Multiple NOT distinct)

Sign up to request clarification or add additional context in comments.

Comments

0

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

SELECT post_title, content
FROM post
GROUP BY post_title, content

1 Comment

it won't show all the duplicated title and contents. thanks though
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 
   )

2 Comments

why not? what is this query returning, and what do you need?
your query select id instead of title. plz see the accepted answer. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.