xpredo
xpredo

Reputation: 1523

how to get duplicate entry from database mysql with id duplicate

i want back ids duplicate from mysql this is my query

>     SELECT COUNT(title) AS duplicate_Count , title , id
>     FROM lyric
>     GROUP BY title
>     HAVING COUNT(title) > 1

and result is this:

duplicate_Count  title id
2     text     121
3     text_2    233

But I'd like this result:

duplicate_Count  title id
2     text     121 , 122
3     text_2    233 ,260 ,56

any help please

Upvotes: 1

Views: 81

Answers (1)

Aziz Saleh
Aziz Saleh

Reputation: 2707

Change id to GROUP_CONCAT(id):

SELECT COUNT(title) AS duplicate_Count , title , GROUP_CONCAT(id)
FROM lyric
GROUP BY title
HAVING COUNT(title) > 1

Example

Upvotes: 2

Related Questions