我正在使用PostgreSQL 9.3。假设我有两个sql-queries返回两个具有完全相同列名的表。例如:
(SELECT id, partner_registration_date
FROM partner) as tbl1
和
(SELECT id, partner_registration_date
FROM partner_statistic) as tbl2
我需要返回一个表格tbl
,以便tbl_ROW_SET = tbl1_ROW_SET ∪ tbl2_ROW_SET
和tbl_COLUMN_SET = tbl1_COLUMN_SET = tbl2_COLUMN_SET
答案 0 :(得分:0)
对于第一种情况,您可以尝试: -
SELECT id, partner_registration_date
FROM partner as tbl1
UNION ALL
SELECT id, partner_registration_date
FROM partner_statistic as tbl2;
第二,你可以尝试: -
SELECT DISTINCT id, partner_registration_date
FROM (SELECT id, partner_registration_date
FROM partner as tbl1
UNION ALL
SELECT id, partner_registration_date
FROM partner_statistic as tbl2);
希望这可以帮到你。