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 |
|
tiffiny
Starting Member
7 Posts |
Posted - 2007-08-09 : 05:30:53
|
| tableAID Name A1 A A2 BA3 CtableBID Main Name ParentB1 A1 aaa B2 A1 bbb B1B3 A1 cccI wish to produce result below without using union,is this posible?ID Name Name NameA1 A aaa A1 A aaa bbbA1 A cccI try to use the query below Select a.ID,a.Name,b.Name,b2.Name from tableA aINNER JOIN tableB b ON a.ID = b.MainLEFT OUTER JOIN tableB AS b2 ON b.ID = b2.Parentbut the result ID Name Name NameA1 A aaa bbbA1 A ccc |
|
|
sutysw
Starting Member
3 Posts |
Posted - 2007-08-09 : 06:05:24
|
| SELECT a.ID, a.Name1, b.Name, b2.Name AS NameParentFROM TableA AS a INNER JOIN TableB AS b ON a.ID = b.Main LEFT OUTER JOIN TableB AS b2 ON b.Parent = b2.ID |
 |
|
|
tiffiny
Starting Member
7 Posts |
Posted - 2007-08-09 : 06:13:49
|
| Thanks for your help! |
 |
|
|
|
|
|