集册 Java 面试笔记 合并的问题

合并的问题

—— 合并

欢马劈雪     最近更新时间:2020-08-04 05:37:59

222

How can you combine two tables/views together? For instance one table contains 100 rows and the other one contains 200 rows, have exactly the same fields and you want to show a query with all data (300 rows).

    SELECT column_name FROM table_name1
    UNION
    SELECT column_name FROM table_name2

注意

  • UNION 内部的 SELECT 语句必须拥有相同数量的列.
  • 列也必须拥有相似的数据类型.
  • 每条 SELECT 语句中的列的顺序必须相同.