mysql

Concatenar varias filas

Me he estado pegando para conseguir en mssql laa función GROUP_CONCAT de mysql:

SELECT 1 AS a, GROUP_CONCAT(name ORDER BY name ASC SEPARATOR ', ') AS people 
FROM users 
WHERE id IN (1,2,3) 
GROUP BY a

En MSSQL:

SELECT STUFF((
    SELECT ';' + name
    FROM users
    FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')
Tags: 
Subscribe to RSS - mysql