user1183513
user1183513

Reputation: 33

Combining 2 views into one in PostgreSQL

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.

Upvotes: 1

Views: 3354

Answers (1)

user554546
user554546

Reputation:

"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.

Upvotes: 3

Related Questions