Reputation: 485
In my database I want to add two views and all columns in one of them to the other.
View one:
|Col1 | Col2 |
| | |
| | |
| | |
View two:
|Col1 | Col3 | Col4| Col5 |
| | | | |
| | | | |
| | | | |
My desired result:
|Col1 | Col2 | Col3 | Col4 |
| | | | |
| | | | |
| | | | |
I have attempted this with solutions like:
SELECT Col1, Col2
FROM view1 NATURAL JOIN(
SELECT Col1, Col2, Col3, Col4
FROM view2);
Ive also tried with other joins but keep getting error that I'm missing key words.
How do I combine the tables the way I wish?
Upvotes: 0
Views: 181
Reputation: 1624
I don't know what are your view's schema, but I am assuming col1 from both views match.
SELECT v1.Col1, v1.Col2, v2.Col3,v2.col4
FROM View1 v1
INNER JOIN -- OR FULL OUTER JOIN based on your desired result
View v2
on
v1.col1=v2.col1 -- AND/OR any other matching columns. I couldn't find any other one
Upvotes: 1