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

SQL - wie man mehrere Tabellen auswählt und mehrere Zeilen aus derselben Spalte JOIN?

Sie können mehrmals an derselben Tabelle teilnehmen, Sie müssen nur unterschiedliche Aliase angeben

SELECT painting.id, 
       painting.order, 
       painting_en.url, 
       `group`.en AS `group`, 
       TYPE.en AS type, 
       location.en AS location
FROM   painting 
       LEFT JOIN painting_en 
       USING (id) 
       LEFT JOIN id_portfolio `group` 
         ON `group`.id = painting.id_group 
       LEFT JOIN id_portfolio TYPE 
         ON TYPE.id = painting.id_type 
       LEFT JOIN id_portfolio location 
         ON location.id = painting.id_location 
WHERE  painting_en.url = '2011-name3' 
LIMIT  1