我有以下查詢,MySQL查詢加入GROUP_CONCAT
SELECT
p.id AS parent, GROUP_CONCAT(c.id) AS children
FROM
rev_r_clients AS p
JOIN
rev_r_clients AS c ON c.parent_client_id = p.id
GROUP BY
p.id
它得到id
爲家長和家長的孩子。從那以後,我送的映射id
使用以下功能陣列,
$parents = Array();
while ($row = $res->fetch_assoc()) {
$parents[$row['parent']] = explode(',',$row['children']);
}
我需要它從另一個表獲得username
(rev_users
)爲好,怎麼能這樣做?
添加到加入rev_users – Mihai