How can I merge the columns from two tables into one output?

前端 未结 5 935
我寻月下人不归
我寻月下人不归 2020-12-07 12:07

I have two tables with similar information. Let\'s call them items_a and items_b. They should be one, but they are coming from different sources, s

5条回答
  •  粉色の甜心
    2020-12-07 12:40

    When your are three tables or more, just add union and left outer join:

    select a.col1, b.col2, a.col3, b.col4, a.category_id 
    from 
    (
        select category_id from a
        union
        select category_id from b
    ) as c
    left outer join a on a.category_id = c.category_id
    left outer join b on b.category_id = c.category_id
    

提交回复
热议问题