sql 语句:
SELECT
(
SELECT
Group_concat(t_work_group_user.user_id)
FROM
t_work_group_user
WHERE
t_work_group_user.work_group_id = workGroup.id
) AS userids,
(
SELECT
Group_concat(t_user.username)
FROM
t_work_group_user
INNER JOIN t_user ON t_user.id = t_work_group_user.user_id
WHERE
t_work_group_user.work_group_id = workGroup.id
) AS usernames,
workGroup.id,
workGroup. NAME,
workGroup.corp_id AS corpId,
workGroup.state,
workGroup.create_time AS createTime
FROM
t_work_group AS workGroup
WHERE
workGroup.state != '0'
结果: