<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: left outer join not working as expected in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836308#M4867151</link>
    <description>&lt;P&gt;re: "How an outer join can become an inner join by means of a WHERE clause"... that was the first SQL question I ever asked online, way back in the last millennium, in the Land Of 1200 Baud, and it was answered by none other than Joe Celko.&lt;/P&gt;</description>
    <pubDate>Tue, 11 Sep 2012 15:33:51 GMT</pubDate>
    <dc:creator>Breck_Carter</dc:creator>
    <dc:date>2012-09-11T15:33:51Z</dc:date>
    <item>
      <title>left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaq-p/13836296</link>
      <description>&lt;P&gt;Please excuse the poor readability, i couldn't figure out how to make underscores show up consistently. I'm using ASA 11 build 2331, 64 bit WinServ 2008.&lt;/P&gt;
&lt;P&gt;This first select works ( it returns 6 rows as expected ). Note that &lt;CODE&gt;e.moved-to-payment-history&lt;/CODE&gt; is part of the left outer join but &lt;CODE&gt;e.moved-to-payment-history&lt;/CODE&gt; does &lt;STRONG&gt;NOT&lt;/STRONG&gt; exist in the oh table.&lt;BR /&gt;
&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c2&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c3&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c4&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;moved&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="k"&gt;to&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt;   
  &lt;SPAN class="k"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;customer&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt; &lt;SPAN class="k"&gt;join&lt;/SPAN&gt; &lt;SPAN class="k"&gt;order&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;header&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt; &lt;SPAN class="k"&gt;on&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt;  
    &lt;SPAN class="k"&gt;left&lt;/SPAN&gt; &lt;SPAN class="k"&gt;outer&lt;/SPAN&gt; &lt;SPAN class="k"&gt;join&lt;/SPAN&gt; &lt;SPAN class="n"&gt;eft&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt; &lt;SPAN class="k"&gt;on&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;invoice&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;number&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;invoice&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;number&lt;/SPAN&gt;  
                    &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;moved&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="k"&gt;to&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'n'&lt;/SPAN&gt;  
 &lt;SPAN class="k"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="k"&gt;open&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;amount&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;lt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="mi"&gt;0&lt;/SPAN&gt;  
    &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'12345'&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;This select does &lt;STRONG&gt;NOT&lt;/STRONG&gt; work ( no rows returned ). This is the SQL that I expected to work ( converted from tSQL *=, see below ). Note that &lt;CODE&gt;e.moved-to-payment-history&lt;/CODE&gt; is in the &lt;CODE&gt;WHERE&lt;/CODE&gt;&lt;BR /&gt;
&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c2&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c3&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c4&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;moved&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="k"&gt;to&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt;   
  &lt;SPAN class="k"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;customer&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt; &lt;SPAN class="k"&gt;join&lt;/SPAN&gt; &lt;SPAN class="k"&gt;order&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;header&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt; &lt;SPAN class="k"&gt;on&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt;  
    &lt;SPAN class="k"&gt;left&lt;/SPAN&gt; &lt;SPAN class="k"&gt;outer&lt;/SPAN&gt; &lt;SPAN class="k"&gt;join&lt;/SPAN&gt; &lt;SPAN class="n"&gt;eft&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt; &lt;SPAN class="k"&gt;on&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;invoice&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;number&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;invoice&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;number&lt;/SPAN&gt;  
   &lt;SPAN class="k"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="k"&gt;open&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;amount&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;lt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="mi"&gt;0&lt;/SPAN&gt;  
    &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;moved&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="k"&gt;to&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'n'&lt;/SPAN&gt;  
    &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'12345'&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;If I use the "old" tSQL *=  this select also works ( 6 rows returned )&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;SELECT&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c2&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c3&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c4&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;moved&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="k"&gt;to&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt;   
  &lt;SPAN class="k"&gt;FROM&lt;/SPAN&gt; &lt;SPAN class="n"&gt;customer&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="k"&gt;order&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;header&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;eft&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt; 
   &lt;SPAN class="k"&gt;WHERE&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt;  
        &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;invoice&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;number&lt;/SPAN&gt; &lt;SPAN class="o"&gt;*=&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;invoice&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="nb"&gt;number&lt;/SPAN&gt;  
        &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="n"&gt;oh&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="k"&gt;open&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;amount&lt;/SPAN&gt; &lt;SPAN class="o"&gt;&amp;lt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="mi"&gt;0&lt;/SPAN&gt;  
    &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="n"&gt;e&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;moved&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;to_payment&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;history&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'n'&lt;/SPAN&gt;  
    &lt;SPAN class="k"&gt;and&lt;/SPAN&gt; &lt;SPAN class="k"&gt;c&lt;/SPAN&gt;&lt;SPAN class="p"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;customer&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;id&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'12345'&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;I've been SLOWLY converting PowerBuilder datawindows from *= to LOJ syntax. What puzzles me is the SQL I expected to work doesn't, and the LOJ that I didn't expect to work does. Explanations from a GURU would be helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2012 18:11:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaq-p/13836296</guid>
      <dc:creator>t1950</dc:creator>
      <dc:date>2012-09-10T18:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836300#M4867143</link>
      <description>&lt;P&gt;FYI code should be indented by 4 spaces - that will make it much easier to read. I've done this for you.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2012 18:27:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836300#M4867143</guid>
      <dc:creator>graeme_perrow</dc:creator>
      <dc:date>2012-09-10T18:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836297#M4867140</link>
      <description>&lt;P&gt;Do the 6 rows from the expected result have values for the e.moved-to-payment-history column? Or is this NULL?&lt;/P&gt;
&lt;P&gt;In case the latter is true: That would be fully expected behaviour:&lt;/P&gt;
&lt;P&gt;Using a filter for a row from the NULL-supplying side of an outer join in the WHERE clause that just accepts TRUE will turn the outer join in an implicit inner join. This is explained in detail in &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbusage/outer-on-joinsasp.html"&gt;this doc page&lt;/A&gt;.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;If e.moved-to-payment-history column is not null, well, then I don't have a clue.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 03:32:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836297#M4867140</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-09-11T03:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836301#M4867144</link>
      <description>&lt;P&gt;The 6 returned rows have nulls as expected.
The Sybase doc explained the outer join logic.&lt;BR /&gt;
Thanks for pointing me in the right direction.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 05:10:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836301#M4867144</guid>
      <dc:creator>t1950</dc:creator>
      <dc:date>2012-09-11T05:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836302#M4867145</link>
      <description>&lt;P&gt;Glad you got it working! If this has helped, feel free to accept the answer - cf. &lt;A href="http://sqlanywhere-forum.sap.com/questions/7748"&gt;this FAQ&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 05:56:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836302#M4867145</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-09-11T05:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836298#M4867141</link>
      <description>&lt;P&gt;Long ago I wrote a &lt;A href="http://www.sybase.com/detail?id=1017447"&gt;whitepaper&lt;/A&gt; on TSQL outer join semantics, which includes ISO SQL-standard equivalents. You may find it helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 07:36:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836298#M4867141</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-09-11T07:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836299#M4867142</link>
      <description>&lt;P&gt;IMO the predicate "e.moved_to_payment_history = 'n'" does not belong in the LEFT OUTER JOIN - ON clause because it doesn't have anything to do with the join.&lt;/P&gt;
&lt;P&gt;Instead, consider applying it to the eft_payment_history table before the LEFT OUTER JOIN.&lt;/P&gt;
&lt;P&gt;Here are three suggested steps in converting the Transact SQL query to ANSI syntax (Caveat Emptor! ...this code has not been tested):&lt;/P&gt;
&lt;PRE&gt;SELECT oh.c1, oh.c2, oh.c3, oh.c4, c.c1, e.moved_to_payment_history   
  FROM customer c, 
       order_header oh, 
       eft_payment_history e 
 WHERE c.customer_id = oh.customer_id  
   and oh.invoice_number *= e.invoice_number  
   and oh.open_amount &amp;lt;&amp;gt; 0  
   and e.moved_to_payment_history = 'n'  
   and c.customer_id = '12345'
&lt;/PRE&gt;

&lt;P&gt;(1) Move the "c.customer_id = oh.customer_id" to the INNER JOIN - ON clause.&lt;/P&gt;
&lt;P&gt;(2) Move the "e.moved_to_payment_history = 'n'" to a derived "( SELECT ... WHERE ... )" table expression so that it is applied to all the actual rows in eft_payment_history before the LEFT OUTER JOIN complicates things.&lt;/P&gt;
&lt;P&gt;(3) Move the "oh.invoice_number *= e.invoice_number" to the LEFT OUTER JOIN - ON clause.&lt;/P&gt;
&lt;PRE&gt;SELECT oh.c1, oh.c2, oh.c3, oh.c4, c.c1, e.moved_to_payment_history   
  FROM customer c  
          INNER JOIN order_header oh 
             ON c.customer_id = oh.customer_id 
          LEFT OUTER JOIN ( SELECT *
                              FROM eft_payment_history e 
                             WHERE e.moved_to_payment_history = 'n'
                          ) AS e
             ON oh.invoice_number = e.invoice_number
 WHERE oh.open_amount &amp;lt;&amp;gt; 0  
   and c.customer_id = '12345'
&lt;/PRE&gt;

&lt;P&gt;Derived tables are very useful to "divide and conquer" complex queries.&lt;/P&gt;
&lt;P&gt;PS: use PRE tags to separate code from text, &lt;/P&gt;
&lt;P&gt;always put a blank line before the opening PRE tag, &lt;/P&gt;
&lt;P&gt;use a backslash before an underscore in ordinary text (not always necessary but it doesn't hurt), and &lt;/P&gt;
&lt;P&gt;don't pay too much attention to the "preview" display, just the final version.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 08:48:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836299#M4867142</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2012-09-11T08:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836303#M4867146</link>
      <description>&lt;P&gt;Thank you for the white paper.&lt;BR /&gt;
I'm passing it on to the other programmers I work with.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 08:50:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836303#M4867146</guid>
      <dc:creator>t1950</dc:creator>
      <dc:date>2012-09-11T08:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836304#M4867147</link>
      <description>&lt;P&gt;A good suggestion - though in this case, personally, I would think the original posted LEFT JOIN query is more readable - derived queries are great tools, but still not that common, methinks.&lt;/P&gt;
&lt;P&gt;(In the end, unless one is aware of this &lt;EM&gt;"How an outer join can become an inner join by means of a WHERE clause"&lt;/EM&gt; issue, both queries would look more difficult than necessary, and the second posted query would be the expected one...)&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 09:43:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836304#M4867147</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-09-11T09:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836305#M4867148</link>
      <description>&lt;P&gt;I would disagree Volker. Derived tables are exceedingly common with outer joins; they offer a great deal more readability when you want to perform an outer join with more than one table, or when there are a number of conditions on the null-supplying table that would appear on the ON condition.&lt;/P&gt;
&lt;P&gt;Breck is right.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 11:16:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836305#M4867148</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-09-11T11:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836306#M4867149</link>
      <description>&lt;P&gt;Well, who am I to debate with you on such topics...&lt;/P&gt;
&lt;P&gt;That being said, if derived queries are more common than I'm aware of, that's good news. (So Breck, there have to be more "Alphas/Betas"...)
Please note, my remark above is explicitly made for that particular query ("in this case") - simply by comparing both queries. As stated, personally, I can surely read and understand the original query more easily. &lt;/P&gt;
&lt;P&gt;For outer joins with more tables and/or conditions, I fully agree with both of you.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 11:32:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836306#M4867149</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-09-11T11:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836307#M4867150</link>
      <description>&lt;P&gt;&lt;A href="https://sqlanywhere-forum.sap.com/users/18/glenn-paulley/"&gt;@Glenn&lt;/A&gt;: BTW and off-topic): What about a fresh debate on surrogate identifiers? Do you have any suggestions for using SA12's sequences to &lt;A href="http://glennpaulley.ca/conestoga/2012/09/surrogate-identifiers/"&gt;generate easily to discriminate identifiers&lt;/A&gt;, such as one&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;might have a customer identifier such XYZ456, a product code of 7877-876, and a supplier identifier of 879BC&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;? I'd be interested:)&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 11:42:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836307#M4867150</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2012-09-11T11:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836308#M4867151</link>
      <description>&lt;P&gt;re: "How an outer join can become an inner join by means of a WHERE clause"... that was the first SQL question I ever asked online, way back in the last millennium, in the Land Of 1200 Baud, and it was answered by none other than Joe Celko.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 15:33:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836308#M4867151</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2012-09-11T15:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: left outer join not working as expected</title>
      <link>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836309#M4867152</link>
      <description>&lt;P&gt;Derived queries are very common... old folks call them "views" and jump through hoops to code CREATE statements... kids today are lazy, and code them in the FROM clause &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2012 15:39:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/left-outer-join-not-working-as-expected/qaa-p/13836309#M4867152</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2012-09-11T15:39:38Z</dc:date>
    </item>
  </channel>
</rss>

