<?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: Join syntax for SQL Query Editor in ST04 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294244#M1989693</link>
    <description>&lt;P&gt;SQL is to be in "native" form (your database system), not Open SQL.&lt;/P&gt;&lt;P&gt;The separator is probably a DOT, not a tilde, not a dash.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * 
    FROM SKAT
    JOIN SKB1
        ON SKAT.SAKNR = SKB1.SAKNR
    WHERE SKB1.KTOPL = 'CADT'
      AND SKB1.BUKRS = '3660'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I also prefer to use upper case, especially with HANA.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Oct 2020 17:58:16 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2020-10-05T17:58:16Z</dc:date>
    <item>
      <title>Join syntax for SQL Query Editor in ST04</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294241#M1989690</link>
      <description>&lt;P&gt;I was going to test a join in the SQL Query Editor in ST04 but I keep getting a syntax error.&lt;BR /&gt;Does anyone here know how the syntax goes in the editor?&lt;/P&gt;
  &lt;P&gt;This gives an error: "invalid column name: SKAT".&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;select * 
    from skat
    join skb1
        on skat-saknr = skb1-saknr
    where ktopl = 'CADT'
        and bukrs = '3660'&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;This gives an error: "sql syntax error: incorrect syntax near "~":".&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;select * 
    from skat
    join skb1
        on skat~saknr = skb1~saknr
    where ktopl = 'CADT'
        and bukrs = '3660'&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;BR /&gt;This gives an error: "sql syntax error: incorrect syntax near "~":".&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;select * 
    from skat as t2
    join skb1 as t1
        on t1~saknr = t2~saknr
    where ktopl = 'CADT'
        and bukrs = '3660'&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;BR /&gt;This gives an error: "Invalid column name: T1".&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;select * 
    from skat as t2
    join skb1 as t1
        on t1-saknr = t2-saknr
    where ktopl = 'CADT'
        and bukrs = '3660'&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thanks and regards,&lt;BR /&gt;Birgir Snorrason&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 14:42:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294241#M1989690</guid>
      <dc:creator>former_member636171</dc:creator>
      <dc:date>2020-10-05T14:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Join syntax for SQL Query Editor in ST04</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294242#M1989691</link>
      <description>&lt;P&gt;Maybe you have to specify the table in the WHERE clause &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select * 
    from skat
    join skb1
        on skat-saknr = skb1-saknr
    where skb1~ktopl = 'CADT'
        and skb1~bukrs = '3660'&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(I don't know if ~ is the good syntax)&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 15:09:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294242#M1989691</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2020-10-05T15:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Join syntax for SQL Query Editor in ST04</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294243#M1989692</link>
      <description>&lt;P&gt;I get the same errors when I add the table in the where clause.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;"sql syntax error: incorrect syntax near "~"" for:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select * 
    from skat
    join skb1
        on skat-saknr = skb1-saknr
    where skb1~ktopl = 'CADT'
        and skb1~bukrs = '3660'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;and "invalid column name: SKAT" for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select * 
    from skat
    join skb1
        on skat-saknr = skb1-saknr
    where skb1-ktopl = 'CADT'
        and skb1-bukrs = '3660'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Oct 2020 15:16:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294243#M1989692</guid>
      <dc:creator>former_member636171</dc:creator>
      <dc:date>2020-10-05T15:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Join syntax for SQL Query Editor in ST04</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294244#M1989693</link>
      <description>&lt;P&gt;SQL is to be in "native" form (your database system), not Open SQL.&lt;/P&gt;&lt;P&gt;The separator is probably a DOT, not a tilde, not a dash.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SELECT * 
    FROM SKAT
    JOIN SKB1
        ON SKAT.SAKNR = SKB1.SAKNR
    WHERE SKB1.KTOPL = 'CADT'
      AND SKB1.BUKRS = '3660'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I also prefer to use upper case, especially with HANA.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 17:58:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294244#M1989693</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-05T17:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Join syntax for SQL Query Editor in ST04</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294245#M1989694</link>
      <description>&lt;P&gt;In ST04 the available functions and options are based on the database connection. And as Sandra already mentioned, the "SQL Editor" for Hana or the "SQL Command Editor" for Oracle (or the SQL Editors for other DBs) need to be used in the corresponding native DB SQL language. OpenSQL cannot be applied. If unsure about the DBs native SQL syntax, use google, although the basic functions and many more advanced functions will be identical.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Alias is defined for tables without AS&lt;/LI&gt;&lt;LI&gt;Alias can be defined for select attributes with and without AS&lt;/LI&gt;&lt;LI&gt;Table is separated from attributes by dot '.'&lt;/LI&gt;&lt;LI&gt;Left and Inner-Join possible&lt;/LI&gt;&lt;LI&gt;When using Left-Join, restrictions need to be for join restrictions&lt;/LI&gt;&lt;LI&gt;Native functions like e.g. substr(string,start,length) or cast(value as type(options)) available&lt;/LI&gt;&lt;LI&gt;Multi-Line comments: /* ....  */&lt;/LI&gt;&lt;LI&gt;In-Line comments: --&lt;/LI&gt;&lt;LI&gt;Following examples work on Oracle and Hana&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE&gt;/*              
Alias for tables without AS  
Alias for select attributes with and without AS possible 
Tables separated from attributes by dot '.'
Native functions like e.g. substr(string,start,length) or cast(value as type(options)) available
Multi-Line Comments start with slash and star and end with star and slash
*/
-- In-Line Comments start with dash dash
/* Inner-Join Example */
SELECT * 
  FROM skat at       
  INNER JOIN skb1 b1 
    ON b1.saknr = at.saknr
 WHERE at.ktopl = 'CADT'
   AND b1.bukrs = '3660'
&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;/* Left-Join Example */              
SELECT at.*, b1.bukrs AS "Company Code"          
  FROM skat at       
  LEFT JOIN skb1 b1
    ON at.saknr = b1.saknr
   AND b1.bukrs = 'CADT'
 WHERE at.ktopl = 'YCOA'
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;PS: SKB1 does not have an attribute KTOPL&lt;/P&gt;</description>
      <pubDate>Mon, 05 Oct 2020 21:20:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294245#M1989694</guid>
      <dc:creator>michael_piesche</dc:creator>
      <dc:date>2020-10-05T21:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Join syntax for SQL Query Editor in ST04</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294246#M1989695</link>
      <description>&lt;P&gt;Link to HANA SQL reference: &lt;A href="https://help.sap.com/viewer/product/SAP_HANA_PLATFORM/2.0.01/en-US?q=SAP+HANA+SQL+and+System+Views+Reference"&gt;SAP HANA SQL and System Views Reference&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2020 06:39:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294246#M1989695</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-10-06T06:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Join syntax for SQL Query Editor in ST04</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294247#M1989696</link>
      <description>&lt;P&gt;Maybe it's too late, but you can do it this way:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;select * 
from skat a join skb1 b
on a.mandt = b.mandt and a.saknr = b.saknr
where b.ktopl ='CADT' and b.bukrs ='3660'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Note that if you are using ST04, you should specify field MANDT also in WHERE clause because the query is cross-client.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 15:39:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/join-syntax-for-sql-query-editor-in-st04/m-p/12294247#M1989696</guid>
      <dc:creator>former_member766248</dc:creator>
      <dc:date>2021-08-10T15:39:39Z</dc:date>
    </item>
  </channel>
</rss>

