Equivalent of MSSQL's STUFF and XML PATH in MYSQL
It looks like you just want to generate a CSV list of people associated with a given task across your table. You may try the following query:
SELECT ta.task_id, GROUP_CONCAT(u.firstname, ' ', u.lastname) AS fullnameFROM teamAlpha taINNER JOIN users u ON u.user_id = ta.user_idGROUP BY ta.user_id;
Note the ugliness of having to use FOR XML PATH
disappears. Though SQL Server has rich support for analytic functions, it's group concatenation support was not so good. In SQL Server 2017 there is a new function STRING_AGG
which basically does the same thing as MySQL's GROUP_CONCAT
.