Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL-Abfrage für mehrere Tabellen, die sekundäre Tabellen mit mehreren Elementen sind?

SELECT g.name, GROUP_CONCAT(c.command) AS commands
FROM site_access b 
    JOIN groups g 
        ON b.group_id = g.id 
    JOIN groups_commands gc
        ON g.id = gc.group_id
    JOIN commands c
        ON gc.command_id = c.id
WHERE b.site_id = 1 
GROUP BY g.name
ORDER BY g.status ASC