table1与table2均为mysql数据库中的表,项目成员表为查询结果,求sql语句。希望大佬指点
SELECT
a.id,
a.project_name,
( SELECT real_name FROM table2 b WHERE a.pm = b.user_id ) AS pm,
(
SELECT
GROUP_CONCAT( table2.real_name ) NAME
FROM
table1
LEFT JOIN table2 ON FIND_IN_SET( table2.user_id, table1.develop_persons )
WHERE
table1.id = a.id
GROUP BY
table1.id
) AS dname,
(
SELECT
GROUP_CONCAT( table2.real_name ) NAME
FROM
table1
LEFT JOIN table2 ON FIND_IN_SET( table2.user_id, table1.test_persons )
WHERE
table1.id = a.id
GROUP BY
table1.id
) AS tname
FROM
table1 a