English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Assume I have two tables:

Table name: coachs

code | from
----------------
0A | Australia
0B | Beligium

Table name: players

code | from
----------------
0C | Columbia
0D | Denmark

I want to join these tables above, into one table or one view:

code | from
----------------
0A | Australia
0B | Beligium
0C | Columbia
0D | Denmark

How to perform this? Step by step please... I'm a begginer. Thank you.

2007-07-01 20:45:07 · 2 answers · asked by Mawan 3 in Computers & Internet Programming & Design

2 answers

select code, [from] from coachs
union all
select code, [from] from players

If you MUST do it with a outer join... you can do this, which should give you the same results. The first way is preferable.

select
isnull(coachs.code, players.code) as code,
isnull(coachs.[from], players.[from]) as [from]
from coachs full join players on 1=0

2007-07-01 20:57:03 · answer #1 · answered by Michael M 6 · 0 0

assuming that you have two tables with exactly same column, I would suggest that you perform UNION instead of OUTER JOIN.

Select * from coachs UNION Select * from players;

would result like what you specify. The alternative would be using SELECT INTO statements for each table to fill the data into the target table and do normal query :

Select * from target;

2007-07-01 21:09:02 · answer #2 · answered by Wind 3 · 0 0

fedest.com, questions and answers