--SQL SERVER
--试图1
create view v_projectuser as
select t.F_ProjectId,t.F_UserId,u.F_ChineseName from T_ProjectUser t,T_User u where t.F_UserId = u.f_id and t.F_Enabled = '1';
--试图2(依赖试图1)
create view v_projectusername as
SELECT a.F_ProjectId ,
STUFF(( SELECT ',' + F_ChineseName
FROM v_projectuser
WHERE F_ProjectId = a.F_ProjectId
FOR
XML PATH('')
), 1, 1, '') AS F_UserNames
FROM v_projectuser a
GROUP BY a.F_ProjectId;
--MySQL
create view v_projectusername as
SELECT
t.F_ProjectId,
GROUP_CONCAT( u.F_ChineseName ) F_UserNames
FROM
t_projectuser t,
t_user u
WHERE
t.F_UserId = u.F_Id
AND t.F_Enabled = '1'
GROUP BY