Mysql
 sql >> Database >  >> RDS >> Mysql

Query MySQL per più tabelle che sono tabelle secondarie più elementi?

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