Search on multiple tables with different columns

前端 未结 1 1845
梦如初夏
梦如初夏 2021-01-29 11:36

I want to build a search engine for my website. My database table list is as follows:

  1. d_name: I need to search on two columns.
  2. <
1条回答
  •  清酒与你
    2021-01-29 12:27

    If you perform an UNION-query all seperate queries should have the same number of columns in the result. You can use fixed values like NULL, '' or 'not provided' to fill up the other tables.

    Examlpe-query (demo)

    SELECT column_1, column_2 FROM i_have_two_columns
    UNION
    SELECT column_1, NULL FROM i_have_only_one_column
    

    0 讨论(0)
提交回复
热议问题