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 |
|
skillile
Posting Yak Master
208 Posts |
Posted - 2002-12-22 : 22:21:19
|
| Here is my result set:count id type9 2 506 3 754 1 25I have 3 tables:Links = 50Articles = 75Programs = 25From the result set at the top I need to join the id to the correct table. So join link data to the 50, article to the 75... .I want to return all rows without using a UNION. Is there a way to either case the INNER JOIN statement or am I missing something.Thanksslow down to move faster... |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-12-22 : 23:39:33
|
| HiYou could LEFT JOIN all your tables on with a case statement i.e.LEFT JOIN Links ON Links.ID = MyTable.ID and MyTable.Type = 50LEFT JOIN Articles ON Articles.ID = MyTable.ID and MyTable.Type = 75LEFT JOIN Programs ON Programs.ID = MyTable.ID and MyTable.Type = 25then use a CASE statement in your select to display the results i.e.SELECT Case Type WHEN 25 THEN Programs.Name WHEN 50 THEN Links.NameWHEN 75 THEN Articles.NameEND as NameetcHope that helpsDamian |
 |
|
|
|
|
|