Vzhledem k vašim datům by tento dotaz měl vracet to, co chcete:
SELECT t1.*,
GROUP_CONCAT(t2.info SEPARATOR '|') AS info,
GROUP_CONCAT(t2.data SEPARATOR '|') AS data
FROM table1 t1 LEFT JOIN
join j
ON j.id_a = t1.id_a LEFT JOIN
table2 t2
ON t2.id_b = j.id_b
WHERE t1.id_a = ?
GROUP BY t1.id_a;
Pokud chcete, můžete duplikáty odstranit pomocí DISTINCT
:
SELECT t1.*,
GROUP_CONCAT(DISTINCT t2.info SEPARATOR '|') AS info,
GROUP_CONCAT(DISTINCT t2.data SEPARATOR '|') AS data
FROM table1 t1 LEFT JOIN
join j
ON j.id_a = t1.id_a LEFT JOIN
table2 t2
ON t2.id_b = j.id_b
WHERE t1.id_a = ?
GROUP BY t1.id_a;
Obvykle je však lepší opravit dotaz, aby negeneroval duplikáty.