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 |
|
mrgr8avill
Starting Member
16 Posts |
Posted - 2007-12-13 : 19:54:11
|
| Hi and thanks for taking the time to read this. I get really confused really quickly when it comes to table linking, and I think I am doing it the hard way. I am going to show my stupidity and ask if there is a better way than what I do, because it takes a LOT of querying and seems like a huge waste.In reality, I have about 20 tables to join like this, but I'm going to use three for the example:"Main" TableAcctNo Name Height Weight1 Bob 1 32 Phil 2 13 Jim 1 54 Lisa 2 2"Height" TableHeightID HeightName1 Giant2 Tall3 Medium4 Short"Weight" TableWeightID W_Name1 Skinny2 Normal3 Overweight4 ObeseWhat I have been doing is:SELECT Main.AcctNo, Main.Name, Height.HeightName, Weight.WeightName FROM Main INNER JOIN Height ON Height.HeightID = Main.Height INNER JOIN Weight ON Weight.WeightID = Main.WeightWHERE Main.AcctNo < 3My question: is doing 20 INNER JOINS really the best way to do this with 20 tables, or is there some other way to link Main.Height to Height.HeightID that is less intensive?Thanks again for reading, and in advance for any information or insight you can provide. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-12-13 : 20:07:52
|
| Joins are the way to go.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|
|