Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
kleinmi
Starting Member
9 Posts |
Posted - 2002-07-10 : 11:00:59
|
| How can I select from a union join? ex.select * from ((select * from table1) union all (select * from table2)) This doesn't work, but this is the basic logic behind what i'm trying to doThanks for any help!Michael |
|
|
MakeYourDaddyProud
184 Posts |
Posted - 2002-07-10 : 11:05:06
|
quote: select * from ( (select * from table1) union all (select * from table2) )
... you are missing a correlation name off the SQLTry...select * from ( select * from table1union allselect * from table2) as Table1_2Remember that the number of columns and datatype for table1 and table2 must match exactlyDaniel Small MIAPwww.danielsmall.com IT Factoring |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-07-10 : 11:06:19
|
Why not:select * from table1 union all select * from table2You don't need to make a subquery out of it.FYI, if you do use a subquery, you need to alias it with a name:select * from (select * from table1 union all select * from table2) AS subQuery Edited by - robvolk on 07/10/2002 11:07:01 |
 |
|
|
MakeYourDaddyProud
184 Posts |
Posted - 2002-07-11 : 03:40:51
|
| Making a subquery of it might be required if the developer wanted to join to the consildated SELECTs as a whole, although performance and table scanning might be an issue.Daniel Small MIAPwww.danielsmall.com IT Factoring |
 |
|
|
|
|
|