mysql union different number of columns

前端 未结 3 601
轻奢々
轻奢々 2021-01-02 11:47

I know union queries have to have the same number of columns. I\'m trying to get results from the table comments and results from the table strings

3条回答
  •  醉话见心
    2021-01-02 12:40

    You would want to select columns as NULL to take up for the empty space in certain tables.

    Table A: (id, column1)

    Table B: (id, column1, column2)

    Select id, column1, null as column2 from tableA
    UNION
    Select id, column1, column2 from tableB
    

提交回复
热议问题