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 |
|
johnstern
Yak Posting Veteran
67 Posts |
Posted - 2007-11-12 : 16:53:53
|
| I am trying to decide which way is the best/efficient way. I have a user table and a usertypelookup table, the relationship is one to one. ( this is only a sample of my actual complex query ) in the first example, for every row I am going to the table and getting the informationin the second one I am join all the tableswhat would you recommed thank you select UserID, (Select UserDescription from UserTypeLookup where UserTypeId = e.UserTypeId) as UserDescription from EmploymentItem ewhere UserRecordId =2 select UserID, UserDescription from EmploymentItem ejoin UserTypeLookup l on e.UserTypeId= l.UserTypeIdwhere UserRecordId =2 edit: added comma to first statement |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-11-12 : 16:57:31
|
| I'd recommend the second option as the first option will break if ever the inner query produces more than one row!Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-11-12 : 17:14:18
|
The first option is not even valid syntax. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Vinnie881
Master Smack Fu Yak Hacker
1231 Posts |
Posted - 2007-11-13 : 01:21:33
|
| Option 2 |
 |
|
|
|
|
|