Combining 2 views into one in PostgreSQL

2019-02-27 18:02发布

I need to do something completely insane. I have 2 views that have the same number of columns (different column names though except the ID column) and they both happen to have 2 existing UNION queries. From my understanding UNION and UNION ALL only work when combining 2 SELECT queries, here I'm trying to combine 4 of them! Aka the 2 views.

1条回答
放我归山
2楼-- · 2019-02-27 18:48

"from my understanding UNION and UNION ALL only work when combining 2 SELECT Queries"

Ummmm...no. You can do something like the following:

select col1,col2
from table
union all
select col1,col2
from some_other_table
union all
select col1,col2
from yet_another_table;

etc, etc.

查看更多
登录 后发表回答