<?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: joinig two tables in select statement in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903907#M376997</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set of hits determined by an inner join can therefore be a subset of the hits determined with an outer join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Database views implement an inner join. The database therefore only provides those records for which there is an entry in all the tables used in the view. Help views and maintenance views, however, implement an outer join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 10 Feb 2007 19:59:37 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-10T19:59:37Z</dc:date>
    <item>
      <title>joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903904#M376994</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 some ex code for how to join two tables in using for statement in select query and also please give me ex code for more than two tables join in select query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Feb 2007 16:35:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903904#M376994</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-10T16:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903905#M376995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Pavan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;For two tables:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;Types: begin of tma,&lt;/P&gt;&lt;P&gt;           matnr type mara-matnr,&lt;/P&gt;&lt;P&gt;           mtart type mara-mtart,&lt;/P&gt;&lt;P&gt;           werks type mard-werks,&lt;/P&gt;&lt;P&gt;           lgort type mard-lgort,&lt;/P&gt;&lt;P&gt;           labst type mard-labst,&lt;/P&gt;&lt;P&gt;           end of tma.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;data: ima type table of tma with header line.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;select mara&lt;SUB&gt;matnr mara&lt;/SUB&gt;mtart mard&lt;SUB&gt;werks mard&lt;/SUB&gt;lgort mard~labst&lt;/P&gt;&lt;P&gt;     into table ima from mara &lt;/P&gt;&lt;P&gt;     inner join mard on mara&lt;SUB&gt;matnr = mard&lt;/SUB&gt;matnr &lt;/P&gt;&lt;P&gt;     up to 10 rows.    &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;LOOP at ima.&lt;/P&gt;&lt;P&gt;    WRITE:/ ima-MATNR, ima-WERKS, ima-mtart, ima-lgort, ima-labst.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Check this code for 3 tables:&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;DATA : BEGIN OF itab OCCURS 0,&lt;/P&gt;&lt;P&gt;matnr LIKE mara-matnr,&lt;/P&gt;&lt;P&gt;ersda LIKE mara-ersda,&lt;/P&gt;&lt;P&gt;werks LIKE mard-werks,&lt;/P&gt;&lt;P&gt;pstat LIKE mard-pstat,&lt;/P&gt;&lt;P&gt;ekgrp LIKE marc-ekgrp,&lt;/P&gt;&lt;P&gt;ausme LIKE marc-ausme,&lt;/P&gt;&lt;P&gt;END OF itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT : mara~matnr&lt;/P&gt;&lt;P&gt;mara~ersda&lt;/P&gt;&lt;P&gt;mard~werks&lt;/P&gt;&lt;P&gt;mard~pstat&lt;/P&gt;&lt;P&gt;marc~ekgrp&lt;/P&gt;&lt;P&gt;marc~ausme&lt;/P&gt;&lt;P&gt;INTO TABLE itab UP TO 20 ROWS&lt;/P&gt;&lt;P&gt;FROM mara&lt;/P&gt;&lt;P&gt;INNER JOIN mard&lt;/P&gt;&lt;P&gt;ON mara&lt;SUB&gt;matnr = mard&lt;/SUB&gt;matnr&lt;/P&gt;&lt;P&gt;INNER JOIN marc&lt;/P&gt;&lt;P&gt;ON mara&lt;SUB&gt;matnr = marc&lt;/SUB&gt;matnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;LOOP AT itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WRITE &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt; itab-matnr,&lt;/P&gt;&lt;P&gt; itab-ersda,&lt;/P&gt;&lt;P&gt; itab-werks,&lt;/P&gt;&lt;P&gt; itab-pstat,&lt;/P&gt;&lt;P&gt; itab-ekgrp,&lt;/P&gt;&lt;P&gt; itab-ausme.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Beejal&lt;/P&gt;&lt;P&gt;**Reward if this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Feb 2007 16:43:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903905#M376995</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-10T16:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903906#M376996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi pavan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;excellent examples given.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The number of resulting lines is the product of matching lines: If there is no matching entry in any of the joined tables, no record is fetched. &lt;/P&gt;&lt;P&gt;If the ON condition matches more than one record in all joined tables, resulting lines give all possible combinations (e.g. MVKE joined on MATNR with MAKT will result sentences number of sales areas multiplied by number of languages maintained).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The join condition is similar to the WHERE condition, it can take expressions combined using logical expressions. Conditions may be specified in ON or in WHERE Clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AND: This is the (default) INNER JOIN. Use (less performant) LEFT OUTER JOIN to fetch initial values when no matching record exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S.: All this can be found in ONLINE DOCUMENTATION. SAP examples are not too useful using confusing alias with AS clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Feb 2007 19:35:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903906#M376996</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2007-02-10T19:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903907#M376997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;good&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join. With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view. With an outer join, records are also selected for which there is no entry in some of the tables used in the view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The set of hits determined by an inner join can therefore be a subset of the hits determined with an outer join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Database views implement an inner join. The database therefore only provides those records for which there is an entry in all the tables used in the view. Help views and maintenance views, however, implement an outer join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_nw04/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04/helpdata/en/67/7e4b3eaf72561ee10000000a114084/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;mrutyun^&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Feb 2007 19:59:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903907#M376997</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-10T19:59:37Z</dc:date>
    </item>
    <item>
      <title>Re: joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903908#M376998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi pavan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this piece of code helps u.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Report zjoin_arun1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;tables : kna1,knb1, knbk.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : begin of itab1 occurs 0,&lt;/P&gt;&lt;P&gt;       kunnr like kna1-kunnr,&lt;/P&gt;&lt;P&gt;       land1 like kna1-land1,&lt;/P&gt;&lt;P&gt;       name1 like kna1-name1,&lt;/P&gt;&lt;P&gt;       ort01 like kna1-ort01,&lt;/P&gt;&lt;P&gt;       regio like kna1-regio,&lt;/P&gt;&lt;P&gt;       bukrs like knb1-bukrs,&lt;/P&gt;&lt;P&gt;       pernr like knb1-pernr,&lt;/P&gt;&lt;P&gt;       end of itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select-options : cust for kna1-kunnr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  select a&lt;SUB&gt;kunnr a&lt;/SUB&gt;land1 a&lt;SUB&gt;name1 a&lt;/SUB&gt;ort01 a&lt;SUB&gt;regio b&lt;/SUB&gt;bukrs b~pernr into&lt;/P&gt;&lt;P&gt;corresponding fields of table itab1 from kna1 as a inner join knb1 as b&lt;/P&gt;&lt;P&gt;  on a&lt;SUB&gt;kunnr eq b&lt;/SUB&gt;kunnr where a~kunnr in cust.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Loop at itab1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Write : / itab1-kunnr, itab1-land1,itab1-name1,&lt;/P&gt;&lt;P&gt;itab1-ort01,itab1-regio, itab1-bukrs,itab1-pernr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arun.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward if it helps u.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 11 Feb 2007 14:33:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903908#M376998</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-11T14:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903909#M376999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; SELECT A&lt;SUB&gt;EQUNR  B&lt;/SUB&gt;DATAB B&lt;SUB&gt;ILOAN &amp;lt;b&amp;gt;C&lt;/SUB&gt;SWERK&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;       INTO TABLE ITEQ&lt;/P&gt;&lt;P&gt;       FROM ( EQUI AS A INNER JOIN EQUZ AS B&lt;/P&gt;&lt;P&gt;       ON A&lt;SUB&gt;EQUNR = B&lt;/SUB&gt;EQUNR ) &amp;lt;b&amp;gt;INNER JOIN ILOA AS C&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;       &amp;lt;b&amp;gt;ON B&lt;SUB&gt;ILOAN = C&lt;/SUB&gt;ILOAN&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;       WHERE A~EQART = 'ESTPL'&lt;/P&gt;&lt;P&gt;       AND B~IWERK = 'M011'&lt;/P&gt;&lt;P&gt;       AND B~INGRP = 'SLM'&lt;/P&gt;&lt;P&gt;       AND B&lt;SUB&gt;DATAB GE SDATE-LOW AND B&lt;/SUB&gt;DATAB LE SDATE-HIGH&lt;/P&gt;&lt;P&gt;       &amp;lt;b&amp;gt;AND C~SWERK IN S_WERK&amp;lt;/b&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This select query is for more than 2 tables &amp;amp; if you want it for 2 tables remove the portion in bold.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Reward if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Sipra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 06:51:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903909#M376999</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T06:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903910#M377000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the sample select query for joining 3 tables.select a&lt;SUB&gt;ematn a&lt;/SUB&gt;ebeln a&lt;SUB&gt;ebelp a&lt;/SUB&gt;menge a&lt;SUB&gt;meins a&lt;/SUB&gt;TXZ01 a~elikz&lt;/P&gt;&lt;P&gt;b~PS_PSP_PNR&lt;/P&gt;&lt;P&gt;c&lt;SUB&gt;ekgrp c&lt;/SUB&gt;bedat c&lt;SUB&gt;lifnr c&lt;/SUB&gt;ekorg&lt;/P&gt;&lt;P&gt;d&lt;SUB&gt;posid e&lt;/SUB&gt;matnr g&lt;SUB&gt;stprs "f&lt;/SUB&gt;lifnr f&lt;SUB&gt;mblnr f&lt;/SUB&gt;mjahr f&lt;SUB&gt;erfmg f&lt;/SUB&gt;erfme&lt;/P&gt;&lt;P&gt;from ekpo as a inner join ekkn as b&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;ebeln eq b&lt;/SUB&gt;ebeln and a&lt;SUB&gt;ebelp eq  b&lt;/SUB&gt;ebelp&lt;/P&gt;&lt;P&gt;inner join ekko as c on a&lt;SUB&gt;ebeln eq c&lt;/SUB&gt;ebeln&lt;/P&gt;&lt;P&gt;inner join prps as d  on b&lt;SUB&gt;ps_psp_pnr eq d&lt;/SUB&gt;pspnr&lt;/P&gt;&lt;P&gt;inner join mdsb as e&lt;/P&gt;&lt;P&gt;on a&lt;SUB&gt;ebeln eq e&lt;/SUB&gt;ebeln and a&lt;SUB&gt;ebelp eq e&lt;/SUB&gt;ebelp&lt;/P&gt;&lt;P&gt;inner join mbew as g on g&lt;SUB&gt;matnr eq e&lt;/SUB&gt;matnr&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;inner join mseg as f on f&lt;SUB&gt;matnr eq e&lt;/SUB&gt;matnr&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;into corresponding fields of table itab where&lt;/P&gt;&lt;P&gt;d~posid in wbs and&lt;/P&gt;&lt;P&gt;c~ekgrp in pgroup and&lt;/P&gt;&lt;P&gt;c~ekorg in purorg and&lt;/P&gt;&lt;P&gt;a~ebeln in purdocno and&lt;/P&gt;&lt;P&gt;c~bedat in pdate and&lt;/P&gt;&lt;P&gt;c~lifnr in vendor .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shankar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 07:15:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903910#M377000</guid>
      <dc:creator>p291102</dc:creator>
      <dc:date>2007-02-12T07:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: joinig two tables in select statement</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903911#M377001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please give me one ex code using for all also to join two tables in select query.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Feb 2007 09:48:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joinig-two-tables-in-select-statement/m-p/1903911#M377001</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-12T09:48:15Z</dc:date>
    </item>
  </channel>
</rss>

