如何将两个表内容连接成sqlite3中的一个表

时间:2017-01-05 18:05:18

标签: sqlite

所有

说我有table1喜欢:

// Object for storing the clustered correspondences.
std::vector<pcl::Correspondences> clusteredCorrespondences;
// Object for storing the transformations (rotation plus translation).
std::vector<Eigen::Matrix4f, Eigen::aligned_allocator<Eigen::Matrix4f> > transformations;

并且table2是相同的结构,如何将它们的内容连接在一起并进行name|id|email 查询

由于

1 个答案:

答案 0 :(得分:1)

您可以使用子查询:

SELECT * FROM (SELECT * FROM table1
               UNION ALL
               SELECT * FROM table2);

或公用表表达式:

WITH newbuildtable AS (
  SELECT * FROM table1
  UNION ALL
  SELECT * FROM table2
)
SELECT * FROM newbuildtable;

或视图:

CREATE VIEW newbuildtable AS
SELECT * FROM table1
UNION ALL
SELECT * FROM table2;

SELECT * FROM newbuildtable;

如果您不想引用原始数据,请将所有数据复制到新表中:

CREATE TABLE newbuildtable AS
SELECT * FROM table1
UNION ALL
SELECT * FROM table2;

SELECT * FROM newbuildtable;