SQL - how to SELECT multiple tables and JOIN multiple rows from the same column?

前端 未结 1 875
眼角桃花
眼角桃花 2021-01-24 03:42

How to SELECT multiple tables and JOIN multiple rows from the same column?

It does not return painting.id_group, painting.id_type and pai

相关标签:
1条回答
  • 2021-01-24 03:48

    You can join to same table multiple times you just need to give different aliases

    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 
    
    0 讨论(0)
提交回复
热议问题