I have a database with one table for Descriptions in different languages, with LanguageID, TableName, ForeignID and Description.
When I need to join this Descriptions table, I naturally join on TableName.ID = ForeignID. But where do you recommend putting the condition for TableName and LanguageID?
Or like this?
asked Dec 20 '10 at 11:49 PM in Default
+1 for WilliamD, but I would add that it's probably better to keep them in the joins because it makes it simpler to modify the query later on. For example, if you want to turn it into a subquery - it's not a big deal. If you want to turn it into a LEFT OUTER join to see which rows don't have corresponding data, it's just a change of the join (whereas there the WHERE clause version actually has a different meaning)...
answered Dec 21 '10 at 12:04 AM
Matt Whitfield ♦♦
As far as I am aware, both of these will result in the same execution plan. I think I prefer the first example, simply because the join conditions are kept together with the joins themselves. The second example makes me look at the joins, then the where clause, then back at the joins to see what the aliases are.
I think it is a thing of preference only.
My 2 cents :o)
answered Dec 20 '10 at 11:59 PM