Mysql
 sql >> Base de données >  >> RDS >> Mysql

MySql a dupliqué des valeurs dans une jointure à l'aide de GROUP_CONCAT

Alors je me réponds. Ce que je cherchais, c'est CONCAT_WS . Ma demande devient alors

SELECT t1.*,
       GROUP_CONCAT(DISTINCT CONCAT_WS(
            ' ', t2.info, t2.data
       ) SEPARATOR  ', ') AS info,
       GROUP_CONCAT(DISTINCT t3.email SEPARATOR '|') AS email
FROM table1 AS t1
LEFT JOIN link1 AS l1
ON l1.id_a = t1.id_a
LEFT JOIN table2 AS t2
ON t2.id_b = l1.id_b
LEFT JOIN link2 AS l2
ON l2.id_a = t1.id_a
LEFT JOIN table3 AS t3
ON t3.id_c = l2.id_c
WHERE t1.id_a = ?
GROUP BY t1.id_a