<?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: Joining 2 tables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086207#M99359</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi You are not selecting any thing from zgtis_qtline&lt;/P&gt;&lt;P&gt;but you are joining..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Dec 2005 15:51:59 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2005-12-05T15:51:59Z</dc:date>
    <item>
      <title>Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086205#M99357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using the following select statement to select from 2 joined tables into an internal table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  select DISTINCT zgtis_qtheader~qtenbr zgtis_qtheader~prjnam
         zgtis_qtheader~status zgtis_qtheader~expdte
    into table t_qtlist
    from zgtis_qtheader
      left join zgtis_qtline on
        ( zgtis_qtheader~mandt  = zgtis_qtline~mandt and
          zgtis_qtheader~qtenbr = zgtis_qtline~qtenbr
      and zgtis_qtheader~vers   = zgtis_qtline~vers )
    where (lv_where).&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The shared key to the two tables is mandt, qtenbr and vers.  I keep receiving the following error message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At least one of the field names in the SELECT clause is not unique.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody tell me what I am doing wrong?  I have each field preceded by the table it is coming from.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 15:48:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086205#M99357</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T15:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086206#M99358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the select caluse is wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 15:51:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086206#M99358</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T15:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086207#M99359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi You are not selecting any thing from zgtis_qtline&lt;/P&gt;&lt;P&gt;but you are joining..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 15:51:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086207#M99359</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T15:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086208#M99360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;  select DISTINCT zgtis_qtheader~qtenbr zgtis_qtheader~prjnam
         zgtis_qtheader~status zgtis_qtheader~expdte
&amp;lt;b&amp;gt;        zgtis_qtline~xyzzz
        zgtis_qtline~abcdde 
        zgtis_qtline~123333&amp;lt;/b&amp;gt;
    into table t_qtlist
    from zgtis_qtheader
      left join zgtis_qtline on
        ( zgtis_qtheader~mandt  = zgtis_qtline~mandt and
          zgtis_qtheader~qtenbr = zgtis_qtline~qtenbr
      and zgtis_qtheader~vers   = zgtis_qtline~vers )
    where (lv_where).&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 15:53:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086208#M99360</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T15:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086209#M99361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In BOLD one try to replace the fields of zgtis_qtline.&lt;/P&gt;&lt;P&gt;then your query will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try to reward for helful answers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 15:55:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086209#M99361</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T15:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086210#M99362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does lv_where look like?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 15:56:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086210#M99362</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T15:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086211#M99363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where clause Did you mentioned in your code is same as you mentioned , what is you are checking there...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:00:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086211#M99363</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:00:20Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086212#M99364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;  Can you describe your Where condition??I guess thats where the problem is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:01:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086212#M99364</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086213#M99365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am really only joining because the where statement uses criteria from the qtline table, but I really only want header values in the table.  I guess you are saying I have to select at least one field from both tables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:02:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086213#M99365</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086214#M99366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Denise,&lt;/P&gt;&lt;P&gt;Thats fine but can you paste the where condition..so that we can be sure that the error is not due to this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:06:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086214#M99366</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086215#M99367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, you don't have to select something from the other table...... this passes a syntax check.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


report zrich_0001 .


data: imara type table of mara with header line.


select distinct mara~matnr mara~matkl
         into corresponding fields of table imara
                from mara
                  left join marc
                      on mara~matnr = marc~matnr
                               where mara~matnr &amp;lt;&amp;gt; space.


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:06:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086215#M99367</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2005-12-05T16:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086216#M99368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah ,thats fine,but you didn't mention it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:06:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086216#M99368</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086217#M99369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you doing something like&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
where qtenbr = 'XXX'
and   vers   = 'YYY'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If so, you have to qualify these names with the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:07:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086217#M99369</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086218#M99370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No need to select from that, But You need to Place some where condition in side where clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:09:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086218#M99370</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086219#M99371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Denise,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The onlu possible reason could be, the system not able to take the table name as alias, can try writing as,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from zgtis_qtheader as h &lt;/P&gt;&lt;P&gt;left join zgtis_qtline as l&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;otherwise, i dont see anything wrong with your select statement...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See below code...it didnt throw any error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: BEGIN OF I_TAB OCCURS 0,&lt;/P&gt;&lt;P&gt;       MATNR TYPE MATNR,&lt;/P&gt;&lt;P&gt;       WERKS TYPE WERKS_D,&lt;/P&gt;&lt;P&gt;       LGORT TYPE LGORT_D,&lt;/P&gt;&lt;P&gt;       DISMM TYPE DISMM,&lt;/P&gt;&lt;P&gt;      END OF I_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT DISTINCT MARC~MATNR&lt;/P&gt;&lt;P&gt;       MARC~WERKS&lt;/P&gt;&lt;P&gt;       MARC~DISMM&lt;/P&gt;&lt;P&gt;       INTO TABLE I_TAB&lt;/P&gt;&lt;P&gt;       FROM MARC LEFT JOIN&lt;/P&gt;&lt;P&gt;            MARD ON&lt;/P&gt;&lt;P&gt;        ( MARD&lt;SUB&gt;MATNR = MARC&lt;/SUB&gt;MATNR AND&lt;/P&gt;&lt;P&gt;          MARD&lt;SUB&gt;WERKS = MARC&lt;/SUB&gt;WERKS ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Raj&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Rajasekhar Dinavahi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Dec 2005 16:12:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086219#M99371</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-05T16:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: Joining 2 tables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086220#M99372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Denise,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There may be nothing else wrong with your code other than your where clause. Whether you use aliases or not doesn't really matter. It is also not necessary that you select at least one field from both the tables you are trying to join. If in your where clause you are trying to compare fields from one of the tables against data in an internal table, try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where zgtis_qtline-"fieldname" in lv_where.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also not that you have to compare individual fields of the table. You cannot compare everything at once.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Feroz Buksh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2005 00:33:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/joining-2-tables/m-p/1086220#M99372</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-12-06T00:33:52Z</dc:date>
    </item>
  </channel>
</rss>

