SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using Exotic Joins in SQL Part 2


Using Exotic Joins in SQL Part 2

Author
Message
ccubley@queryplan.com
ccubley@queryplan.com
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 3
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/ccubley/usingexoticjoinsinsqlpart2.asp


Chris Cubley
www.queryplan.com
AjarnMark
AjarnMark
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 55
Good article with valuable information, but it appears that this has a repeated typo. Shouldn't s.RoomNumber = s.RoomNumber be s.RoomNumber = c.RoomNumber?



nlcapit
nlcapit
Grasshopper
Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)Grasshopper (19 reputation)

Group: General Forum Members
Points: 19 Visits: 85
Is there an advantage in putting the inequality in the join statement rather than in a WHERE clause? Does the query run faster?

example:

SELECT s.CourseID,s.SectionNumber,
c.RoomCapacity, s.SectionCapacity
FROM tb_ClassSection s
INNER JOIN tb_Classroom c
ON ( s.BuildingName = c.BuildingName
AND s.RoomNumber = s.RoomNumber)
WHERE c.RoomCapacity < s.SectionCapacity



bjmarte
bjmarte
SSC-Enthusiastic
SSC-Enthusiastic (113 reputation)SSC-Enthusiastic (113 reputation)SSC-Enthusiastic (113 reputation)SSC-Enthusiastic (113 reputation)SSC-Enthusiastic (113 reputation)SSC-Enthusiastic (113 reputation)SSC-Enthusiastic (113 reputation)SSC-Enthusiastic (113 reputation)

Group: General Forum Members
Points: 113 Visits: 1
quote:

Is there an advantage in putting the inequality in the join statement rather than in a WHERE clause? Does the query run faster?

example:

SELECT s.CourseID,s.SectionNumber,
c.RoomCapacity, s.SectionCapacity
FROM tb_ClassSection s
INNER JOIN tb_Classroom c
ON ( s.BuildingName = c.BuildingName
AND s.RoomNumber = s.RoomNumber)
WHERE c.RoomCapacity < s.SectionCapacity



That would be my questions too. Too bad there's no answer.



ccubley
ccubley
SSC Rookie
SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)SSC Rookie (43 reputation)

Group: General Forum Members
Points: 43 Visits: 1
I don't know of any performance difference from putting the join criteria of an inner join into the where clause rather than the from clause. However, I always put join criteria (comparisons between columns of tables) in the from clause for consistency's sake because there IS a difference when it comes to outer joins. By doing it the same for inner and outer joins, things are easier down the road if you need to change the code.

Chris Cubley
www.queryplan.com



quote:

quote:

Is there an advantage in putting the inequality in the join statement rather than in a WHERE clause? Does the query run faster?

example:

SELECT s.CourseID,s.SectionNumber,
c.RoomCapacity, s.SectionCapacity
FROM tb_ClassSection s
INNER JOIN tb_Classroom c
ON ( s.BuildingName = c.BuildingName
AND s.RoomNumber = s.RoomNumber)
WHERE c.RoomCapacity < s.SectionCapacity



That would be my questions too. Too bad there's no answer.







Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search