Ich habe die folgende SQL wählen:Mehrere LEFT JOIN in mehreren Tabellen
SELECT s.*,
GROUP_CONCAT(CONCAT_WS(':', m.type, m.id, m.filename) SEPARATOR ',') AS multimedia,
GROUP_CONCAT(CONCAT_WS(':', c.id) SEPARATOR ',') AS categories
FROM sections s
LEFT JOIN sections_multimedia sm
ON s.id = sm.section_id
LEFT JOIN multimedia m
ON sm.multimedia_id = m.id
LEFT JOIN sections_categories sc
ON s.id = sc.section_id
LEFT JOIN categories c
ON sc.category_id = c.id
WHERE s.id = s.id
GROUP BY s.id
ORDER BY s.position, s.id ASC;
Als Ergebnis das Feld ‚Kategorien‘ hat die richtigen Werte, die (2,3), aber leider oft wiederholt ! (das Ergebnis ist: 2,2,2,2,2,2,3,3,3,3,3,3)
Was ist los mit meiner Auswahl?
Vielen Dank für Ihre Antworten!
Ihr Titel sagt innere schließt sich aber Ihre Abfrage wird mit der linken verbindet? – dbajtr
Mein Fehler! Ich habe den Titel bearbeitet! Vielen Dank! – Nick
Was machen Sie mit diesem Ergebnis? – Strawberry