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 |
sqlclarify
Yak Posting Veteran
56 Posts |
Posted - 2008-08-07 : 00:09:51
|
Hello,Is it possible to join a union with another sql statement.for example lets say we have:select FirstName As Names from NamestableUnionselect lastName As Names from LastNamesTableso this produces the output:Names-----abc etc.we want to join this with another attribute which is produced by the lets say the following statement:select age from AgesTableWe want :Names | Age----- ------a | x b | y c | zHow do we write the statement for this using a where clause? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-08-07 : 00:23:48
|
How do you relate a to x, b to y etc ? KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-08 : 15:01:13
|
if you have a relation between AgesTable and each of Namestable,LastNamesTable you can do it with a derived table containing the union.select * from(select FirstName As Names from NamestableUnionselect lastName As Names from LastNamesTable)tjoin AgesTable aon a.linkingcol=t.Names |
|
|
|
|
|