Monday, 15 August 2011

mysql - Trying to remove duplicate rows of data after using coalesce -



mysql - Trying to remove duplicate rows of data after using coalesce -

i have table has 1 record each type of access users have:

cm812 brtyf78 cm812 brgh5vd cm812 ghyf7gj

i want query table , get:

cm812 brtyf78,brgh5vd,ghyf7gj

this wrote:

select id ,coalesce(access+',' ,'') + (access) access [accesslist] grouping id, access

what is:

cm812 brtyf78,brgh5vd,ghyf7gj cm812 brtyf78,brgh5vd,ghyf7gj cm812 brtyf78,brgh5vd,ghyf7gj

how 1 entry of???:

cm812 brtyf78,brgh5vd,ghyf7gj

sql server fiddle:

select a.id, substring(( select ', ' + b.access accesslist b b.id = a.id order access xml path('')),2,8000) accesslist accesslist grouping a.id

mysql fiddle:

select a.id, group_concat(access order access separator ', ') accesslist accesslist grouping a.id

mysql sql sql-server

No comments:

Post a Comment