MySql - Create view to read from Multiple Tables

前端 未结 2 772
不知归路
不知归路 2021-01-28 18:11

I have archived some old line items for invoices that are no longer current but still need to reference them. I think I need to create a VIEW but not really understanding it. Ca

2条回答
  •  不要未来只要你来
    2021-01-28 18:40

    You can use UNION :

    SELECT a.* FROM a 
      UNION
    SELECT b.* FROM b;
    

    You just need to have the same number and type of column in your different queries. As far as I remember, you can add test in sub-queries, but I'm not sure you can order on the global result.

    http://dev.mysql.com/doc/refman/4.1/en/union.html

提交回复
热议问题