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

前端 未结 5 950
我寻月下人不归
我寻月下人不归 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:48

    I had a similar problem with a small difference: some a.category_id are not in b and some b.category_id are not in a.
    To solve this problem just adapt the excelent answer from beny23 to

    select a.col1, b.col2, a.col3, b.col4, a.category_id 
    from items_a a
    LEFT OUTER JOIN
    items_b b 
    on a.category_id = b.category_id
    

    Hope this helps someone.
    Regards.

提交回复
热议问题