<?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>topic Re: Is this SQL Statement correct? in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846332#M924737</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alex Arthur Sam...  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just follow this Inner join syntax &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT FLD1 FLD2 FLD3 FLD4 FLD5 INTO CORRESPONDING FIELDS OF TABLE ITAB FROM TABLE1 INNER JOIN TABLE2 ON &lt;/P&gt;&lt;P&gt;TABLE1&lt;SUB&gt;FLD1 = TABLE2&lt;/SUB&gt;FLD1 INNER JOIN TABLE3 ON TABLE2&lt;SUB&gt;FLD2 = TABLE3&lt;/SUB&gt;FLD2 INNER JOIN TABL4 ON  TABLE3&lt;SUB&gt;FLD3 = TABLE4&lt;/SUB&gt;FLD3 &lt;/P&gt;&lt;P&gt; WHERE FLD1 = 'AA'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this may solve your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please reward points if found useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rajeshwar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 May 2008 05:50:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-15T05:50:19Z</dc:date>
    <item>
      <title>Is this SQL Statement correct?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846331#M924736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to avoid a subquery and created an INNER JOIN, could anyone tell me whether they are the same or different from the given below SQL statment?. The internal table is already defined etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Inner Join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;begda a&lt;/SUB&gt;endda a&lt;SUB&gt;objid a&lt;/SUB&gt;sobid b~sobid &lt;/P&gt;&lt;P&gt;FROM hrp1001 AS a&lt;/P&gt;&lt;P&gt;      INNER JOIN hrp1001 AS b ON a&lt;SUB&gt;objid = b&lt;/SUB&gt;objid  AND&lt;/P&gt;&lt;P&gt;                                      b~subty = 'A008'   AND&lt;/P&gt;&lt;P&gt;                                      b~sclas = 'P'&lt;/P&gt;&lt;P&gt;INTO  TABLE itab_allper&lt;/P&gt;&lt;P&gt;WHERE a&lt;SUB&gt;subty = 'A003' AND a&lt;/SUB&gt;sclas = 'O' and a~endda = '99991231'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Equivalent in Subquery&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;begda a&lt;/SUB&gt;endda a&lt;SUB&gt;objid a&lt;/SUB&gt;sobid b~sobid INTO TABLE itab_allper &lt;/P&gt;&lt;P&gt;FROM hrp1001 as a&lt;/P&gt;&lt;P&gt;WHERE  a~subty = 'A003' and&lt;/P&gt;&lt;P&gt;              a~sclas = 'O'    and&lt;/P&gt;&lt;P&gt;              a~objid in (SELECT objid FROM HRP1001 as b &lt;/P&gt;&lt;P&gt;                              WHERE b~subty = 'A008' and&lt;/P&gt;&lt;P&gt;                                           b~sclas = 'O').&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also if I want to  display all columns based on objid that are not matching from table b, should I put LEFT OUTTER JOIN instead of INNER JOIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Alex.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 May 2008 16:29:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846331#M924736</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-14T16:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is this SQL Statement correct?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846332#M924737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alex Arthur Sam...  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just follow this Inner join syntax &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT FLD1 FLD2 FLD3 FLD4 FLD5 INTO CORRESPONDING FIELDS OF TABLE ITAB FROM TABLE1 INNER JOIN TABLE2 ON &lt;/P&gt;&lt;P&gt;TABLE1&lt;SUB&gt;FLD1 = TABLE2&lt;/SUB&gt;FLD1 INNER JOIN TABLE3 ON TABLE2&lt;SUB&gt;FLD2 = TABLE3&lt;/SUB&gt;FLD2 INNER JOIN TABL4 ON  TABLE3&lt;SUB&gt;FLD3 = TABLE4&lt;/SUB&gt;FLD3 &lt;/P&gt;&lt;P&gt; WHERE FLD1 = 'AA'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this may solve your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please reward points if found useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rajeshwar.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2008 05:50:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846332#M924737</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-15T05:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is this SQL Statement correct?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846333#M924738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alex,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;begda a&lt;/SUB&gt;endda a&lt;SUB&gt;objid a&lt;/SUB&gt;sobid b~sobid &lt;/P&gt;&lt;P&gt;FROM hrp1001 AS a&lt;/P&gt;&lt;P&gt;INNER JOIN hrp1001 AS b ON a&lt;SUB&gt;objid = b&lt;/SUB&gt;objid AND&lt;/P&gt;&lt;P&gt;b~subty = 'A008' AND&lt;/P&gt;&lt;P&gt;b~sclas = 'P'&lt;/P&gt;&lt;P&gt;INTO TABLE itab_allper&lt;/P&gt;&lt;P&gt;WHERE a&lt;SUB&gt;subty = 'A003' AND a&lt;/SUB&gt;sclas = 'O' and a~endda = '99991231'.&lt;/P&gt;&lt;P&gt;In the above query, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;b~subty = 'A008' AND&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;b~sclas = 'P'&lt;/STRONG&gt;  is not the JOIN condition. So, it would be better if you put those conditions in the WHERE clause, instead, as shown below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT a&lt;SUB&gt;begda a&lt;/SUB&gt;endda a&lt;SUB&gt;objid a&lt;/SUB&gt;sobid b~sobid &lt;/P&gt;&lt;P&gt;FROM hrp1001 AS a&lt;/P&gt;&lt;P&gt;INNER JOIN hrp1001 AS b ON a&lt;SUB&gt;objid = b&lt;/SUB&gt;objid &lt;/P&gt;&lt;P&gt;INTO TABLE itab_allper&lt;/P&gt;&lt;P&gt;WHERE a~subty = 'A003' and &lt;/P&gt;&lt;P&gt;a~sclas = 'O' and &lt;/P&gt;&lt;P&gt;a~endda = '99991231' and&lt;/P&gt;&lt;P&gt;b~subty = 'A008' and&lt;/P&gt;&lt;P&gt;b~sclas = 'P'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also ur interpretaion regarding the LEFT OUTER JOIN is correct. In case u want to display all columns based on objid that are not matching from table b, u should use LEFT OUTER JOIN .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't forget to reward points, if this is useful.&lt;/P&gt;&lt;P&gt;Pavan.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2008 07:33:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846333#M924738</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-15T07:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Is this SQL Statement correct?</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846334#M924739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 May 2008 16:28:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/is-this-sql-statement-correct/m-p/3846334#M924739</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-15T16:28:38Z</dc:date>
    </item>
  </channel>
</rss>

