﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Chris Cubley / Article Discussions / Article Discussions by Author  / Using Exotic Joins in SQL Part 1 / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 21:13:08 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>One of the poorest articles I have read in the long time. Theta join is by no means an exotic operator. Set equality and set containment join is. Google "relational division"</description><pubDate>Wed, 29 Aug 2007 09:54:00 GMT</pubDate><dc:creator>John Q Public-431253</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;You can write query like this: &lt;/P&gt;&lt;P&gt;suppose say you are passing two parameters name @StartDate and @EndDate and you column name in table is TransDate&lt;/P&gt;&lt;P&gt;TransDate BETWEEN ISNULL(@StartDate, TransDate) AND ISNULL(@EndDate, TransDate)&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;img src='images/emotions/smile.gif' height='20' width='20' border='0' title='Smile' align='absmiddle'&gt;&lt;/P&gt;&lt;P&gt;Rohit&lt;/P&gt;</description><pubDate>Wed, 03 May 2006 05:23:00 GMT</pubDate><dc:creator>ROhit Shrivastava</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;TABLE cellSpacing=1 cellPadding=0 width="100%" border=0&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=ForumsBody1 vAlign=top width=175 nowarp&gt;&lt;/TD&gt;&lt;TD class=ForumsBody1 vAlign=top&gt;&lt;TABLE height="100%" cellSpacing=0 cellPadding=5 width="100%" border=0&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=ForumsBody1 vAlign=top&gt;&lt;SPAN id=Showtread1_ThreadRepeater__ctl8_lblFullMessage&gt;&lt;TABLE class=quote cellSpacing=1 cellPadding=5&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD vAlign=top noWrap width=11&gt;&lt;IMG height=13 alt=quote src="http://www.sqlservercentral.com/forums/images/quoteicon.gif" width=11 align=absMiddle&gt;&lt;/TD&gt;&lt;TD width="99%"&gt;&lt;P&gt;BETWEEN is purely simpler to read. There is no specific engine enhancements that make BETWEEN any faster.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;P&gt; &lt;/P&gt;&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;2cents more..."Between" is not ANSI 92 standard, so using &amp;lt; and &amp;gt; is more portable.</description><pubDate>Mon, 02 May 2005 18:15:00 GMT</pubDate><dc:creator>Calvin Lawson</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;You say that dropping the support for the WHERE clause is breaking away from the ANSI standard.  It is the ANSI standard that has pshed the move to using the FROM clause for Joins and not the WHERE clause.  Based on that how would this move by Microsoft be considered a move away from the ANSI standard?  Even if the latest standard allows for joins in the FROM and WHERE clause the fact that the preferred method of joins is in the FROM clause I would think that sticking with usisng the WHERE clause would actually be a move away from the ANSI standard.&lt;/P&gt;&lt;P&gt;PLease understand that I am not trying to sound negative or attack your comment, I know personally how emails and postings are poor at properly conveying emotions.  I am merely trying to understand why you feel this way and try to find out if maybe I have missed something or have improperly understood the ANSI standard.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Ed&lt;/P&gt;</description><pubDate>Mon, 02 May 2005 09:26:00 GMT</pubDate><dc:creator>YSLGuru</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;P&gt;I think you can use the following sql to do your work&lt;/P&gt;&lt;P&gt;select * from My_Table&lt;/P&gt;&lt;P&gt;where col_date between isnull(@Start_Date, '1900-01-01') and isnull(@End_Date, '2999-01-01')&lt;/P&gt;&lt;P&gt;Assume your real date is no earlier than '1900-01-01' and no later than '2999-01-01')&lt;/P&gt;</description><pubDate>Fri, 29 Apr 2005 09:51:00 GMT</pubDate><dc:creator>jeffrey yao</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;P&gt;What about performance using this methodology?There are many articles about using "SARG"able methodologies which allow indexes to operate correctly.&lt;A href="http://www.databasejournal.com/features/mssql/article.php/1436301"&gt;http://www.databasejournal.com/features/mssql/article.php/1436301&lt;/A&gt;&lt;A href="http://www.windowsitpro.com/SQLServer/Article/ArticleID/42349/42349.html"&gt;http://www.windowsitpro.com/SQLServer/Article/ArticleID/42349/42349.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It appears that the JOIN portion is SARGable, but how do we know for sure since the join seems to now operate onmultiple values?&lt;/P&gt;&lt;P&gt;INNER JOIN      tb_GradeScale g      ON(            s.NumericGrade BETWEEN g.MinNumeric AND g.MaxNumeric      )&lt;/P&gt;&lt;P&gt;- B&lt;/P&gt;</description><pubDate>Fri, 29 Apr 2005 09:26:00 GMT</pubDate><dc:creator>Bilster-223920</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>I have frequent need to use BETWEEN type logic for date ranges, where the start date or the end date (or both) may be null.If just the start date is null, I want anything earlier than the end date.If just the end date is null, I want anything later than the start date.If both are null, I want all records.I can do this with a user defined function - but want to know if there is a particularly efficient way to approach it. Performance is an issue.</description><pubDate>Fri, 29 Apr 2005 08:11:00 GMT</pubDate><dc:creator>Parker Smith</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;P&gt;BETWEEN is purely simpler to read. There is no specific engine enhancements that make BETWEEN any faster.&lt;/P&gt;</description><pubDate>Fri, 29 Apr 2005 08:09:00 GMT</pubDate><dc:creator>Antares686</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;P&gt;Hello Chris&lt;/P&gt;&lt;P&gt;Please excuse a question from a newbie, but is there an advantage in using the between operator as opposed to using &amp;gt;= and &amp;lt;= comparisons. &lt;/P&gt;&lt;P&gt;Looking at the execution plans of some of my queries it seems to make no difference to the plan structure or cost of the query replacing &amp;gt;= and &amp;lt;= with between in either the WHERE or from clause, but it certainly makes the syntax a bit neater. &lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description><pubDate>Fri, 29 Apr 2005 02:15:00 GMT</pubDate><dc:creator>David le Quesne</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>&lt;P&gt;As somebody who works in education, I use this type of construct on a regular basis. It would be nice to see an example with real numbers rather than integers. Typically you end up writing it as &lt;/P&gt;&lt;DL&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;SELECT&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;&lt;SPAN style="mso-tab-count: 1"&gt;      &lt;/SPAN&gt;s.StudentID,&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;&lt;SPAN style="mso-tab-count: 1"&gt;      &lt;/SPAN&gt;g.LetterGrade&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;FROM&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;&lt;SPAN style="mso-tab-count: 1"&gt;      &lt;/SPAN&gt;tb_StudentGrade s&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;INNER JOIN&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;&lt;SPAN style="mso-tab-count: 1"&gt;      &lt;/SPAN&gt;tb_GradeScale g&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;          ON(&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;(s.NumericGrade &amp;gt;= g.MinNumeric) AND (s.NumericGrade &amp;lt; g.MaxNumeric)&lt;/DIV&gt;&lt;/DT&gt;&lt;DT&gt;&lt;DIV class=SQLCode&gt;)&lt;/DIV&gt;&lt;/DT&gt;&lt;/DL&gt;&lt;P class=SQLCode&gt;Which may or may not be the best way.&lt;/P&gt;</description><pubDate>Fri, 29 Apr 2005 02:08:00 GMT</pubDate><dc:creator>jfmccabe</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>I think Microsoft may actually be toeing the line on this one... It used to be okay to use *= or =* in the WHERE clause for OUTER JOIN, however, sometimes the use of such sometimes leads to ambiguous queries... I don't have an example handy, it's too early in the morning. &lt;img src=icon_smile_sleepy.gif border=0 align=middle&gt; You almost get the feeling that the standard may evolve to where none of the JOIN syntax can be in the WHERE clause. But to be honest, I don't see the INNER JOIN syntax in the WHERE clause going away anytime soon. K. Brian Kelleyhttp://www.truthsolutions.com/Author: Start to Finish Guide to SQL Server Performance Monitoring http://www.netimpress.com/shop/product.asp?ProductID=NI-SQL1</description><pubDate>Tue, 04 Feb 2003 06:53:00 GMT</pubDate><dc:creator>K. Brian Kelley</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>I'm not sure how they could drop support for the WHERE clause.  If they are then they would be breaking away from ANSI standard SQL and force a paradigm shift on their user base.If it ain't broke.....&lt;img src=icon_smile_wink.gif border=0 align=middle&gt; </description><pubDate>Tue, 04 Feb 2003 02:28:00 GMT</pubDate><dc:creator>David.Poole</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>The benefit of doing these type of joins in the FROM clause rather than the WHERE clause is the same as it is for an equijoin.  For inner joins, the two different syntaxes are equivelent.  For outer joins, performing the joins in the WHERE clause will cause non-matched rows to be excluded.  This is because any comparison to NULL (i.e. 5 = NULL, NULL = NULL, NULL BETWEEN 5 AND 20) returns false.  Furthermore, Microsoft recommends that all joins be done in the FROM clause and warns that support for WHERE clause joins may be dropped in future versions of SQL Server.Chris Cubleywww.queryplan.comChris Cubleywww.queryplan.com</description><pubDate>Mon, 03 Feb 2003 21:14:00 GMT</pubDate><dc:creator>ccubley@queryplan.com</dc:creator></item><item><title>RE: Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>Is there any benefit in using these sort of joins instead of using the WHERE clause? </description><pubDate>Mon, 03 Feb 2003 03:37:00 GMT</pubDate><dc:creator>David.Poole</dc:creator></item><item><title>Using Exotic Joins in SQL Part 1</title><link>http://www.sqlservercentral.com/Forums/Topic9382-89-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/ccubley/usingexoticjoinsinsql.asp&gt;http://www.sqlservercentral.com/columnists/ccubley/usingexoticjoinsinsql.asp&lt;/A&gt;</description><pubDate>Sun, 19 Jan 2003 00:00:00 GMT</pubDate><dc:creator>ccubley@queryplan.com</dc:creator></item></channel></rss>