<?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: joins in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138191#M745761</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the result is '12345' if the content of wa_pmd2-fff_lead = '01234'. May be I was not that clear in the first posting. The result is the result of the above query. To visualize it better you're probably right. For the Query:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT a~prikey, a~matnr, b~prikey, b~matnr
  FROM picps AS b
  JOIN picps AS a
    ON b~pickey = a~pickey
 WHERE a~matnr = wa_pmd2-fff_lead
   AND b~matnr NE wa_pmd2-fff_lead.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result for wa_pmd2-fff_lead = '01234' would be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
a~prikey a~matnr b~prikey b~matnr
-------- ------- -------- ------- 
pickey1  01234   pickey1  12345
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore you'll get '12345' as the result of the original query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Ralph&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Dec 2007 10:03:35 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-12-13T10:03:35Z</dc:date>
    <item>
      <title>joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138185#M745755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELECT b~matnr INTO TABLE i_picps &lt;/P&gt;&lt;P&gt;    FROM picps as b &lt;/P&gt;&lt;P&gt;      JOIN picps as a &lt;/P&gt;&lt;P&gt;          ON b&lt;SUB&gt;pickey = a&lt;/SUB&gt;pickey &lt;/P&gt;&lt;P&gt;          WHERE a~matnr = wa_pmd2-fff_lead &lt;/P&gt;&lt;P&gt;                AND b~matnr NE wa_pmd2-fff_lead. &lt;/P&gt;&lt;P&gt;The proposed query will retrieve the non-lead parts from PICPS for the given lead part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can anyone help me in understanding the above SELECT query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2007 14:34:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138185#M745755</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-12T14:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138186#M745756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can me tell me area of the fun., bcz this table is not available in our system&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2007 17:25:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138186#M745756</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-12T17:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138187#M745757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is joining a table on itself - not a common thing to do, but it is permitted. Since the WHERE can never be true, nothing will be selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems to be a very awkward attempt to set SY-SUBRC = '4'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2007 18:12:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138187#M745757</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-12T18:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138188#M745758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why do you think that the result set is empty? If you assume that pickey is not  the primary key of the table, the result set could be not empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If we assume that table picps has the columns &amp;lt;i&amp;gt;client&amp;lt;/i&amp;gt;, &amp;lt;i&amp;gt;pk&amp;lt;/i&amp;gt;, &amp;lt;i&amp;gt;pickey&amp;lt;/i&amp;gt; and &amp;lt;i&amp;gt;matnr&amp;lt;/i&amp;gt; and it contains the following rows (primary key: client, pk):&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
client pk    pickey  matnr
------ ----- ------ ------
001    Key1  pickey1 01234
001    Key2  pickey1 12345
001    Key3  pickey2 67890
001    Key4  pickey2 67890
001    Key5  pickey3 23456
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There result set would be for a lead part = 01234:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
matnr
------
12345
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Syed:&lt;/P&gt;&lt;P&gt;A self join is not that rare, it could be used if entities which are stored in a table has a relation with other entities of the same type stored in the same table. What Rob assumed is that prickey is the primary key of your table (which may be is true), then the predicates of your query lead to an empty set. This is because the join picks only rows from the table with the same value in the column pickey. If this is the primary key, the joined set consists of rows which have all columns as doubles. That mean a&lt;SUB&gt;matnr is always equal to b&lt;/SUB&gt;matnr, which means your where clause could not be true.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Ralph&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2007 22:46:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138188#M745758</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-12T22:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138189#M745759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good point - I am assuming it's the primary key.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2007 01:59:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138189#M745759</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-13T01:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138190#M745760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Ralph,&lt;/P&gt;&lt;P&gt;good illustration&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But is the result really always 01234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it is not clear, it can also be 12345&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore the fieldlist is a bit weird. It should probably be key1 matnr  key2 matr2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siegfried&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2007 07:45:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138190#M745760</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-13T07:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138191#M745761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Siegfried,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the result is '12345' if the content of wa_pmd2-fff_lead = '01234'. May be I was not that clear in the first posting. The result is the result of the above query. To visualize it better you're probably right. For the Query:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
SELECT a~prikey, a~matnr, b~prikey, b~matnr
  FROM picps AS b
  JOIN picps AS a
    ON b~pickey = a~pickey
 WHERE a~matnr = wa_pmd2-fff_lead
   AND b~matnr NE wa_pmd2-fff_lead.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result for wa_pmd2-fff_lead = '01234' would be:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
a~prikey a~matnr b~prikey b~matnr
-------- ------- -------- ------- 
pickey1  01234   pickey1  12345
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore you'll get '12345' as the result of the original query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Ralph&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2007 10:03:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138191#M745761</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-13T10:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: joins</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138192#M745762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ralph for your explanation&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2007 12:17:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joins/m-p/3138192#M745762</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-12-14T12:17:31Z</dc:date>
    </item>
  </channel>
</rss>

