Hosam alzagh Hosam alzagh - 7 months ago 8
SQL Question

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 same this


duplicate_Count title id
2 text 121
3 text_2 233


please i want get result same this


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


any help please

Answer

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

Comments