<?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: Problem in Select Statment in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237980#M482136</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Nelson.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;... [(] {dbtab_left [AS tabalias_left]} | join &lt;/P&gt;&lt;P&gt;{[INNER] JOIN}|{LEFT [OUTER] JOIN} &lt;/P&gt;&lt;P&gt;{dbtab_right [AS tabalias_right] ON join_cond} [)] ... . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At least one comparison must be specified after ON. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Individual comparisons may be joined using AND only. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following language elements may not be used: BETWEEN, LIKE, IN. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No sub-queries may be used. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For outer joins, only equality comparisons (=, EQ) are possible. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resulting set for inner join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resulting set for outer join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_cityfr TYPE spfli-cityfrom, &lt;/P&gt;&lt;P&gt;p_cityto TYPE spfli-cityto. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa, &lt;/P&gt;&lt;P&gt;fldate TYPE sflight-fldate, &lt;/P&gt;&lt;P&gt;carrname TYPE scarr-carrname, &lt;/P&gt;&lt;P&gt;connid TYPE spfli-connid, &lt;/P&gt;&lt;P&gt;END OF wa. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA itab LIKE SORTED TABLE OF wa &lt;/P&gt;&lt;P&gt;WITH UNIQUE KEY fldate carrname connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT c&lt;SUB&gt;carrname p&lt;/SUB&gt;connid f~fldate &lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;FROM ( ( scarr AS c &lt;/P&gt;&lt;P&gt;INNER JOIN spfli AS p ON p&lt;SUB&gt;carrid = c&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND p~cityfrom = p_cityfr &lt;/P&gt;&lt;P&gt;AND p~cityto = p_cityto ) &lt;/P&gt;&lt;P&gt;INNER JOIN sflight AS f ON f&lt;SUB&gt;carrid = p&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND f&lt;SUB&gt;connid = p&lt;/SUB&gt;connid ). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa. &lt;/P&gt;&lt;P&gt;WRITE: / wa-fldate, wa-carrname, wa-connid. &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;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS p_cityfr TYPE spfli-cityfrom. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa, &lt;/P&gt;&lt;P&gt;carrid TYPE scarr-carrid, &lt;/P&gt;&lt;P&gt;carrname TYPE scarr-carrname, &lt;/P&gt;&lt;P&gt;connid TYPE spfli-connid, &lt;/P&gt;&lt;P&gt;END OF wa, &lt;/P&gt;&lt;P&gt;itab LIKE SORTED TABLE OF wa &lt;/P&gt;&lt;P&gt;WITH NON-UNIQUE KEY carrid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT s&lt;SUB&gt;carrid s&lt;/SUB&gt;carrname p~connid &lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;FROM scarr AS s &lt;/P&gt;&lt;P&gt;LEFT OUTER JOIN spfli AS p ON s&lt;SUB&gt;carrid = p&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND p~cityfrom = p_cityfr. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa. &lt;/P&gt;&lt;P&gt;IF wa-connid = '0000'. &lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-carrname. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we r using 2 type of joins in abap they are&lt;/P&gt;&lt;P&gt;1) inner join.&lt;/P&gt;&lt;P&gt;this will join 2 tables using an common fiend and return the result with field values wich are common in both the tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1 itab2&lt;/P&gt;&lt;P&gt;a b c a d &lt;/P&gt;&lt;P&gt;1 2 3 1 5 &lt;/P&gt;&lt;P&gt;2 3 4 3 6&lt;/P&gt;&lt;P&gt;after innerjoining itab1 n itab2 on field a we wil get the o/p as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a b c d &lt;/P&gt;&lt;P&gt;1 2 3 5&lt;/P&gt;&lt;P&gt;only common field is taken..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)left outer join&lt;/P&gt;&lt;P&gt;here it wil work in opossite way it will give values whic are not common&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1 itab2&lt;/P&gt;&lt;P&gt;a b c a d &lt;/P&gt;&lt;P&gt;1 2 3 1 5 &lt;/P&gt;&lt;P&gt;2 3 4 3 6&lt;/P&gt;&lt;P&gt;after left outer joining itab1 n itab2 on field a we wil get the o/p as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a b c d &lt;/P&gt;&lt;P&gt;2 3 4 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;only fields which are not common is taken from the left table..other field(d here) wil be empty&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it will help u.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward Points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Amber s&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 May 2007 06:26:24 GMT</pubDate>
    <dc:creator>former_member198270</dc:creator>
    <dc:date>2007-05-07T06:26:24Z</dc:date>
    <item>
      <title>Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237977#M482133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;TAB1&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;F1&amp;lt;/u&amp;gt;	&amp;lt;u&amp;gt;F2&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;A1	AA&lt;/P&gt;&lt;P&gt;A2	AA&lt;/P&gt;&lt;P&gt;A3	BB&lt;/P&gt;&lt;P&gt;A4	AA&lt;/P&gt;&lt;P&gt;A5	AA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;TAB2&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;u&amp;gt;F1&amp;lt;/u&amp;gt;	&amp;lt;u&amp;gt;F2&amp;lt;/u&amp;gt;	&amp;lt;u&amp;gt;F3&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;B1	AA	D1&lt;/P&gt;&lt;P&gt;B2	BB	D1&lt;/P&gt;&lt;P&gt;B3	CC	D1&lt;/P&gt;&lt;P&gt;B4	AA	D2&lt;/P&gt;&lt;P&gt;B5	AA	D3&lt;/P&gt;&lt;P&gt;B6	BB	D1&lt;/P&gt;&lt;P&gt;B7	AA	D1&lt;/P&gt;&lt;P&gt;B8	DD	D1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I use following statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select F1 from TAB1 where TAB1.F2 in (Select F2 from TAB2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It&amp;#146;s working properly with my requirement.&lt;/P&gt;&lt;P&gt;My problem is now I want to get field F1 in TAB2 also. How can I get this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally I needed result is&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;T&amp;lt;u&amp;gt;AB1-F1&amp;lt;/u&amp;gt;	&amp;lt;u&amp;gt;TAB2-F1&amp;lt;/u&amp;gt;&lt;/P&gt;&lt;P&gt;A1		B1	&lt;/P&gt;&lt;P&gt;A2		B1&lt;/P&gt;&lt;P&gt;A3		B2&lt;/P&gt;&lt;P&gt;A4		B1&lt;/P&gt;&lt;P&gt;A5		B1&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Basically I want,  when TAB1-F2  data in TAB2-F2 field I want get TAB2-F1 field also.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:17:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237977#M482133</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T06:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237978#M482134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nelson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use outer joins on two tables TAB1 and TAB2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;plz reward points if helpful or if it solves ur query.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chinmay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:20:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237978#M482134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T06:20:23Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237979#M482135</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;PRE&gt;&lt;CODE&gt;SELECT S~F1 S~F2 P~F1
INTO   CORRESPONDING FIELDS OF TABLE IT_ITAB
FROM   TAB1 AS S
       INNER JOIN TAB2 AS P ON S~F2  =  P~F2 .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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; Sudheer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:22:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237979#M482135</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T06:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237980#M482136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Nelson.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Syntax &lt;/P&gt;&lt;P&gt;... [(] {dbtab_left [AS tabalias_left]} | join &lt;/P&gt;&lt;P&gt;{[INNER] JOIN}|{LEFT [OUTER] JOIN} &lt;/P&gt;&lt;P&gt;{dbtab_right [AS tabalias_right] ON join_cond} [)] ... . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Effect &lt;/P&gt;&lt;P&gt;The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At least one comparison must be specified after ON. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Individual comparisons may be joined using AND only. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following language elements may not be used: BETWEEN, LIKE, IN. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;No sub-queries may be used. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For outer joins, only equality comparisons (=, EQ) are possible. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resulting set for inner join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resulting set for outer join &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS: p_cityfr TYPE spfli-cityfrom, &lt;/P&gt;&lt;P&gt;p_cityto TYPE spfli-cityto. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa, &lt;/P&gt;&lt;P&gt;fldate TYPE sflight-fldate, &lt;/P&gt;&lt;P&gt;carrname TYPE scarr-carrname, &lt;/P&gt;&lt;P&gt;connid TYPE spfli-connid, &lt;/P&gt;&lt;P&gt;END OF wa. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA itab LIKE SORTED TABLE OF wa &lt;/P&gt;&lt;P&gt;WITH UNIQUE KEY fldate carrname connid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT c&lt;SUB&gt;carrname p&lt;/SUB&gt;connid f~fldate &lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;FROM ( ( scarr AS c &lt;/P&gt;&lt;P&gt;INNER JOIN spfli AS p ON p&lt;SUB&gt;carrid = c&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND p~cityfrom = p_cityfr &lt;/P&gt;&lt;P&gt;AND p~cityto = p_cityto ) &lt;/P&gt;&lt;P&gt;INNER JOIN sflight AS f ON f&lt;SUB&gt;carrid = p&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND f&lt;SUB&gt;connid = p&lt;/SUB&gt;connid ). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa. &lt;/P&gt;&lt;P&gt;WRITE: / wa-fldate, wa-carrname, wa-connid. &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;&lt;/P&gt;&lt;P&gt;Example &lt;/P&gt;&lt;P&gt;Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PARAMETERS p_cityfr TYPE spfli-cityfrom. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF wa, &lt;/P&gt;&lt;P&gt;carrid TYPE scarr-carrid, &lt;/P&gt;&lt;P&gt;carrname TYPE scarr-carrname, &lt;/P&gt;&lt;P&gt;connid TYPE spfli-connid, &lt;/P&gt;&lt;P&gt;END OF wa, &lt;/P&gt;&lt;P&gt;itab LIKE SORTED TABLE OF wa &lt;/P&gt;&lt;P&gt;WITH NON-UNIQUE KEY carrid. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT s&lt;SUB&gt;carrid s&lt;/SUB&gt;carrname p~connid &lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE itab &lt;/P&gt;&lt;P&gt;FROM scarr AS s &lt;/P&gt;&lt;P&gt;LEFT OUTER JOIN spfli AS p ON s&lt;SUB&gt;carrid = p&lt;/SUB&gt;carrid &lt;/P&gt;&lt;P&gt;AND p~cityfrom = p_cityfr. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa. &lt;/P&gt;&lt;P&gt;IF wa-connid = '0000'. &lt;/P&gt;&lt;P&gt;WRITE: / wa-carrid, wa-carrname. &lt;/P&gt;&lt;P&gt;ENDIF. &lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;we r using 2 type of joins in abap they are&lt;/P&gt;&lt;P&gt;1) inner join.&lt;/P&gt;&lt;P&gt;this will join 2 tables using an common fiend and return the result with field values wich are common in both the tables&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1 itab2&lt;/P&gt;&lt;P&gt;a b c a d &lt;/P&gt;&lt;P&gt;1 2 3 1 5 &lt;/P&gt;&lt;P&gt;2 3 4 3 6&lt;/P&gt;&lt;P&gt;after innerjoining itab1 n itab2 on field a we wil get the o/p as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a b c d &lt;/P&gt;&lt;P&gt;1 2 3 5&lt;/P&gt;&lt;P&gt;only common field is taken..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)left outer join&lt;/P&gt;&lt;P&gt;here it wil work in opossite way it will give values whic are not common&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab1 itab2&lt;/P&gt;&lt;P&gt;a b c a d &lt;/P&gt;&lt;P&gt;1 2 3 1 5 &lt;/P&gt;&lt;P&gt;2 3 4 3 6&lt;/P&gt;&lt;P&gt;after left outer joining itab1 n itab2 on field a we wil get the o/p as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a b c d &lt;/P&gt;&lt;P&gt;2 3 4 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;only fields which are not common is taken from the left table..other field(d here) wil be empty&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it will help u.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward Points if helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Amber s&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:26:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237980#M482136</guid>
      <dc:creator>former_member198270</dc:creator>
      <dc:date>2007-05-07T06:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237981#M482137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi nelso,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try with this sample code in this u have to do only thing is to replace the fields with your required tables and use join condition and where condition like shown below it will work properly &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT  ekko~lifnr ekko~ebeln ekko~knumv ekko~bedat
          ekpo~werks ekpo~matnr ekpo~txz01 ekpo~werks
          ekpo~netwr
*          ekpo~aedat
          ekbe~ebelp  ekbe~belnr
          lfa1~name1
  INTO    CORRESPONDING   FIELDS OF  TABLE int_outtab

  FROM ( ( ( ekko

           JOIN ekbe ON  ekbe~ebeln = ekko~ebeln AND
                         ekbe~vgabe = '2'       )
           JOIN ekpo ON ekpo~ebeln = ekko~ebeln   AND
                        ekpo~ebelp = ekbe~ebelp )
           JOIN lfa1 ON lfa1~lifnr = ekko~lifnr )
  WHERE  ekko~lifnr  =  P_lifnr  AND
         ekko~ebeln IN  S_ebeln  AND
*         ekpo~werks IN  S_werks AND
         ekbe~vgabe = '2'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rewards if helpfull&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:27:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237981#M482137</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T06:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237982#M482138</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;Modify your query as this n try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select TAB1&lt;SUB&gt;F1 TAB2&lt;/SUB&gt;F1 &lt;/P&gt;&lt;P&gt;into table tab3&lt;/P&gt;&lt;P&gt;from TAB1 &lt;/P&gt;&lt;P&gt;inner join TAB2&lt;/P&gt;&lt;P&gt;on TAB1&lt;SUB&gt;F2 EQ TAB2&lt;/SUB&gt;F2&lt;/P&gt;&lt;P&gt;for all entries in tab2&lt;/P&gt;&lt;P&gt;where tab1&lt;SUB&gt;f2 eq tab2&lt;/SUB&gt;f2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Asha Raghuvanshi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:31:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237982#M482138</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T06:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237983#M482139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dear all &lt;/P&gt;&lt;P&gt;i dont want to repeat TAB1-F1 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i wanna just mapped 1 record from TAB2-F2&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:40:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237983#M482139</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T06:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in Select Statment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237984#M482140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok then if u want map only one field u can use COMPARE statement or else u can use join condition as i hav sown above &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 May 2007 06:50:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-in-select-statment/m-p/2237984#M482140</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-07T06:50:17Z</dc:date>
    </item>
  </channel>
</rss>

