SQL Join Style, Anything Wrong With This
-
יום שלישי 21 אוגוסט 2012 13:06
I work in a team environment and came across some using this style of SQL. I think this is old style, but not sure if there is anything wrong with it and if I should tell this person not to use this style.
So, this is what I'm seeing...
Instead of doing
Select From Table1 Join Table2 On Table1.col = Table2.col
I see this person doing
Select From Table1, Table2 Where Table1.col = Table2.col
Other than style, is there anything wrong with this and do i have a legitimate reason to point this out?
כל התגובות
-
יום שלישי 21 אוגוסט 2012 13:09מנחה דיון
There is nothing wrong except the style. However, if you're working as a team, it's better to use JOIN style with explicit INNER JOIN syntax. Depending on the relations in the team it makes sense to politely bring this topic up and suggest to use ANSI JOIN style in the queries.For every expert, there is an equal and opposite expert. - Becker's Law
My blog- הוצע כתשובה על-ידי Sygrien יום שלישי 21 אוגוסט 2012 14:05
-
יום שלישי 21 אוגוסט 2012 13:21
Yes, I'm not liking this style. The person happens to be the team lead and not sure how touchy the person will get.
-
יום שלישי 21 אוגוסט 2012 13:22מנחה דיון
Is the second style more troublesome to the query optimizer if the table list becomes long?
Also, keep in mind that if the query needs to include an outer join that the outer join should be joined with LEFT JOIN, RIGHT JOIN or FULL JOIN rather than the comma delimited style with the *= or =* style. Moreover, the *= is deprecated and should be removed if you are still dealing with it.
- נערך על-ידי Kent WaldropMicrosoft Community Contributor, Moderator יום שלישי 21 אוגוסט 2012 13:26
- נערך על-ידי Kent WaldropMicrosoft Community Contributor, Moderator יום שלישי 21 אוגוסט 2012 13:33
- סומן כתשובה על-ידי D00linDalton יום שני 27 אוגוסט 2012 14:17
-
יום שלישי 21 אוגוסט 2012 13:27מנחה דיוןI see, hard situation. I can not advise anything then as I used to come into scruples myself before.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog -
יום שלישי 21 אוגוסט 2012 13:52
Is the second style more troublesome to the query optimizer if the table list becomes long?
Also, keep in mind that if the query needs to include an outer join that the outer join should be joined with LEFT JOIN, RIGHT JOIN or FULL JOIN rather than the comma delimited style with the *= or =* style. Moreover, the *= is deprecated and should be removed if you are still dealing with it.
This is an objective technical reason. So, I will use this when the time is right.- סומן כתשובה על-ידי D00linDalton יום שני 27 אוגוסט 2012 14:17
-
יום שלישי 21 אוגוסט 2012 14:11
Personally, I have a hard time keeping track of joins using the second method when the list is more than a couple tables. At my workplace we still have some queries that use that syntax, and the rule is that if you are working on a proc that has the old syntax, you update it to the new ANSI syntax.
If you don't want to deal with him, you could always try to get Joe Celko to talk to him.
- הוצע כתשובה על-ידי Naomi NMicrosoft Community Contributor, Moderator יום שלישי 21 אוגוסט 2012 14:18
- סומן כתשובה על-ידי D00linDalton יום שני 27 אוגוסט 2012 14:17
-
יום שלישי 21 אוגוסט 2012 14:19מנחה דיון
:)
But I think Joe uses where style also, at least often in his samples.
BTW, I also often correct the queries if I come across some and also I like to add dbo to the tables used in the query as I know using two part naming convention is better, preferred method and even make them execute faster ( 1 nano second).
For every expert, there is an equal and opposite expert. - Becker's Law
My blog- נערך על-ידי Naomi NMicrosoft Community Contributor, Moderator יום שלישי 21 אוגוסט 2012 14:21