<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Where is my WHERE?</title>
	<atom:link href="http://technology.amis.nl/2007/12/21/where-is-my-where/feed/" rel="self" type="application/rss+xml" />
	<link>http://technology.amis.nl/2007/12/21/where-is-my-where/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=where-is-my-where</link>
	<description></description>
	<lastBuildDate>Fri, 12 Apr 2013 10:04:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Steve Pratt</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5095</link>
		<dc:creator>Steve Pratt</dc:creator>
		<pubDate>Tue, 01 Jul 2008 15:21:06 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5095</guid>
		<description><![CDATA[Back in the &#039;old&#039; days of RDBMSes, sometimes it was necessary to fool the optimizer in order to force a specific access path.  And one technique was to include an absolute truth in the WHERE clause.   (this was obviously before the advent of optimizer HINTS.)]]></description>
		<content:encoded><![CDATA[<p>Back in the &#8216;old&#8217; days of RDBMSes, sometimes it was necessary to fool the optimizer in order to force a specific access path.  And one technique was to include an absolute truth in the WHERE clause.   (this was obviously before the advent of optimizer HINTS.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Nuijten</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5094</link>
		<dc:creator>Alex Nuijten</dc:creator>
		<pubDate>Sun, 23 Dec 2007 09:31:03 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5094</guid>
		<description><![CDATA[Thank you for the link, Rob. Very enlightening....]]></description>
		<content:encoded><![CDATA[<p>Thank you for the link, Rob. Very enlightening&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Borkur Steingrimsson</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5093</link>
		<dc:creator>Borkur Steingrimsson</dc:creator>
		<pubDate>Fri, 21 Dec 2007 14:51:09 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5093</guid>
		<description><![CDATA[well, the error you get

ERROR at line 15:
ORA-25154: column part of USING clause cannot have qualifier

is exactly that. You can not put anywhere in your statement things like &quot;t.id =3&quot;  (in the SELECT or the WHERE clause) as the error message suggests. Instead you would have to put just  &quot;id = 3&quot;, without the table alias (qualifier). This also applies to doing something like &quot; SELECT S.* from ...&quot; and then ANSI JOIN with the USING keyword. It would result in the same error being raised. If you alter your example to reflect this, you will then see that the USING part does not extend outside of the parentheses and the WHERE keyword must follow before you put other predicates.]]></description>
		<content:encoded><![CDATA[<p>well, the error you get</p>
<p>ERROR at line 15:<br />
ORA-25154: column part of USING clause cannot have qualifier</p>
<p>is exactly that. You can not put anywhere in your statement things like &#8220;t.id =3&#8243;  (in the SELECT or the WHERE clause) as the error message suggests. Instead you would have to put just  &#8220;id = 3&#8243;, without the table alias (qualifier). This also applies to doing something like &#8221; SELECT S.* from &#8230;&#8221; and then ANSI JOIN with the USING keyword. It would result in the same error being raised. If you alter your example to reflect this, you will then see that the USING part does not extend outside of the parentheses and the WHERE keyword must follow before you put other predicates.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob van Wijk</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5092</link>
		<dc:creator>Rob van Wijk</dc:creator>
		<pubDate>Fri, 21 Dec 2007 11:17:55 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5092</guid>
		<description><![CDATA[Alex,

As said, you converted a predicate to a join condition. This can be done safely for inner joins, i.e. it doesn&#039;t affect the result of your query, but if you do the same for an outer join the result set may change. See this article from Jonathan Gennick about this behaviour: http://www.oreillynet.com/pub/a/network/2002/10/01/whatsinacondition.html

Regards,
Rob.]]></description>
		<content:encoded><![CDATA[<p>Alex,</p>
<p>As said, you converted a predicate to a join condition. This can be done safely for inner joins, i.e. it doesn&#8217;t affect the result of your query, but if you do the same for an outer join the result set may change. See this article from Jonathan Gennick about this behaviour: <a href="http://www.oreillynet.com/pub/a/network/2002/10/01/whatsinacondition.html" rel="nofollow">http://www.oreillynet.com/pub/a/network/2002/10/01/whatsinacondition.html</a></p>
<p>Regards,<br />
Rob.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Nuijten</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5091</link>
		<dc:creator>Alex Nuijten</dc:creator>
		<pubDate>Fri, 21 Dec 2007 10:36:18 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5091</guid>
		<description><![CDATA[Thank you all for your comments. I took the liberty to place them into the main section of the post, as the layout in the comments section is less than ideal. :)]]></description>
		<content:encoded><![CDATA[<p>Thank you all for your comments. I took the liberty to place them into the main section of the post, as the layout in the comments section is less than ideal. <img src='http://technology.amis.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niall Litchfield</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5090</link>
		<dc:creator>Niall Litchfield</dc:creator>
		<pubDate>Fri, 21 Dec 2007 10:32:03 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5090</guid>
		<description><![CDATA[OK lets see if the pre tag is accepted so you can see what I mean

SELECT
      first_col
,     second_col
...
...
,     last_col
FROM
      first_tab join second_tab
      on (join clause)
WHERE
      first_condition
and second_condition
and ...
GROUP BY
      first groupby
,     second groupby
...
HAVING
     first having
,    second having
...
ORDER BY
     first_col
,    second_col]]></description>
		<content:encoded><![CDATA[<p>OK lets see if the pre tag is accepted so you can see what I mean</p>
<p>SELECT<br />
      first_col<br />
,     second_col<br />
&#8230;<br />
&#8230;<br />
,     last_col<br />
FROM<br />
      first_tab join second_tab<br />
      on (join clause)<br />
WHERE<br />
      first_condition<br />
and second_condition<br />
and &#8230;<br />
GROUP BY<br />
      first groupby<br />
,     second groupby<br />
&#8230;<br />
HAVING<br />
     first having<br />
,    second having<br />
&#8230;<br />
ORDER BY<br />
     first_col<br />
,    second_col</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niall Litchfield</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5089</link>
		<dc:creator>Niall Litchfield</dc:creator>
		<pubDate>Fri, 21 Dec 2007 10:31:06 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5089</guid>
		<description><![CDATA[The comment out issue is one reason why I use the writing style

SELECT
      first_col
,     second_col
...
...
,     last_col
FROM
      first_tab join second_tab
      on (join clause)
WHERE
      first_condition
and second_condition
and ...
GROUP BY
      first groupby
,     second groupby
...
HAVING
     first having
,    second having
...
ORDER BY
     first_col
,    second_col


i.e KEYWORDS on their own, start lines with a , (if appropriate) I also find it more readable.

Incidentally many sql generators - programs that generate sql based on forms etc - will start the where with 1=1 so they don&#039;t have to work out which is the first condition.]]></description>
		<content:encoded><![CDATA[<p>The comment out issue is one reason why I use the writing style</p>
<p>SELECT<br />
      first_col<br />
,     second_col<br />
&#8230;<br />
&#8230;<br />
,     last_col<br />
FROM<br />
      first_tab join second_tab<br />
      on (join clause)<br />
WHERE<br />
      first_condition<br />
and second_condition<br />
and &#8230;<br />
GROUP BY<br />
      first groupby<br />
,     second groupby<br />
&#8230;<br />
HAVING<br />
     first having<br />
,    second having<br />
&#8230;<br />
ORDER BY<br />
     first_col<br />
,    second_col</p>
<p>i.e KEYWORDS on their own, start lines with a , (if appropriate) I also find it more readable.</p>
<p>Incidentally many sql generators &#8211; programs that generate sql based on forms etc &#8211; will start the where with 1=1 so they don&#8217;t have to work out which is the first condition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Borkur Steingrimsson</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5088</link>
		<dc:creator>Borkur Steingrimsson</dc:creator>
		<pubDate>Fri, 21 Dec 2007 10:10:40 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5088</guid>
		<description><![CDATA[Well, this is for sure not a bug. This is really normal and expected behavior. The ON clause extends to line 7 in your last example, since you don&#039;t have to use parenthesis. If you had written something like

SQL&gt; select
  2       *
  3    from t
  4    join s
  5      USING (id) --Notice the difference here
  6  â€”- where t.id = 3
  7     and s.id = 3
  8  /

Then your query would fail.

Regarding leaving a &quot;1=1&quot; in production could, whilst not being very clean or pretty, I would not find it likely to cause a lot overhead :) I wonder how many queries per second you would need to be able to measure the effect of it ..]]></description>
		<content:encoded><![CDATA[<p>Well, this is for sure not a bug. This is really normal and expected behavior. The ON clause extends to line 7 in your last example, since you don&#8217;t have to use parenthesis. If you had written something like</p>
<p>SQL&gt; select<br />
  2       *<br />
  3    from t<br />
  4    join s<br />
  5      USING (id) &#8211;Notice the difference here<br />
  6  â€”- where t.id = 3<br />
  7     and s.id = 3<br />
  8  /</p>
<p>Then your query would fail.</p>
<p>Regarding leaving a &#8220;1=1&#8243; in production could, whilst not being very clean or pretty, I would not find it likely to cause a lot overhead <img src='http://technology.amis.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I wonder how many queries per second you would need to be able to measure the effect of it ..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dominic Brooks</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5087</link>
		<dc:creator>Dominic Brooks</dc:creator>
		<pubDate>Fri, 21 Dec 2007 10:05:58 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5087</guid>
		<description><![CDATA[&#039;where 1=1&#039; is often also used by code that dynamically generates queries depending on inputs, presumably so it doesn&#039;t need to figure out whether a dynamically generated predicate should use &#039;where&#039; or &#039;and&#039;.]]></description>
		<content:encoded><![CDATA[<p>&#8216;where 1=1&#8242; is often also used by code that dynamically generates queries depending on inputs, presumably so it doesn&#8217;t need to figure out whether a dynamically generated predicate should use &#8216;where&#8217; or &#8216;and&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marco Gralike</title>
		<link>http://technology.amis.nl/2007/12/21/where-is-my-where/#comment-5086</link>
		<dc:creator>Marco Gralike</dc:creator>
		<pubDate>Fri, 21 Dec 2007 09:50:27 +0000</pubDate>
		<guid isPermaLink="false">http://technology.amis.nl/blog/?p=2673#comment-5086</guid>
		<description><![CDATA[Ehhh... &quot;where 1=1&quot;, if it remains in the production code, isn&#039;t it also a performance degradation issue (doing an unneeded check that costs at least CPU time?)]]></description>
		<content:encoded><![CDATA[<p>Ehhh&#8230; &#8220;where 1=1&#8243;, if it remains in the production code, isn&#8217;t it also a performance degradation issue (doing an unneeded check that costs at least CPU time?)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
