Reputation: 17929
I need to create a view (or a table) that holds n row values, taken from two different tables that have the same structure. For example:
table Europe
id name Country
----------------------------
1 Franz Germany
2 Alberto Italy
3 Miguel Spain
table USA
id name Country
----------------------------
1 John USA
2 Matthew USA
The merged view has to be like this:
table WORLD
id name Country
----------------------------
1 John USA
2 Matthew USA
1 Franz Germany
2 Alberto Italy
3 Miguel Spain
it's possible? if it is, how?
Thanks in advance for your help, best regards
Upvotes: 5
Views: 22621
Reputation: 2010
if you just want to result than try union query
SELECT id,name,Country FROM dbo.Europe
UNION
SELECT id,name,Country FROM dbo.USA
Upvotes: 9
Reputation: 36438
You can create a reusable view of the union like so:
create view allcountries as select * from usa union select * from world;
(name it anything you like in place of allcountries
)
then just:
select * from allcountries;
Upvotes: 3