<?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 How to SQL Query an external database and a saved JMP table? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51588#M29248</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Within a JMP script I really need to query both a saved JMP table and a seperate database table, but cannot work out how or find a solution online.&amp;nbsp;There is&amp;nbsp;a simplified example code below. The issue is once I have connected to the db I can no longer Query local tables. I know I could do a&amp;nbsp;table join in JMP after the SQL Query on the external db, but the&amp;nbsp;goal is to only pull customers specified in the customers.jmp table in the query to reduce how much data it needs to query. I have tried things such as&amp;nbsp;JOIN 'cust',&amp;nbsp;JOIN 'Customers' etc.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// open JMP table
cust = Open( "***\JMP Tables\Customers.jmp");

//connect to DB
SQLConnection = Create database connection("DRIVER=*** SERVER=***; DATABASE=database; Uid=***;Pwd=***");

//Query both
PrePUSQL01 =
"
SELECT
T.CustomerID,
C.Inc
FROM database.dbo.table AS T
JOIN cust AS C ON C.CustomerID = T.CustomerID
WHERE C.Inc = '1'
"　
;
dt = Execute SQL(SQLConnection, 
PrePUSQL01,
"dt"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Feb 2018 12:09:16 GMT</pubDate>
    <dc:creator>david707</dc:creator>
    <dc:date>2018-02-20T12:09:16Z</dc:date>
    <item>
      <title>How to SQL Query an external database and a saved JMP table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51588#M29248</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Within a JMP script I really need to query both a saved JMP table and a seperate database table, but cannot work out how or find a solution online.&amp;nbsp;There is&amp;nbsp;a simplified example code below. The issue is once I have connected to the db I can no longer Query local tables. I know I could do a&amp;nbsp;table join in JMP after the SQL Query on the external db, but the&amp;nbsp;goal is to only pull customers specified in the customers.jmp table in the query to reduce how much data it needs to query. I have tried things such as&amp;nbsp;JOIN 'cust',&amp;nbsp;JOIN 'Customers' etc.&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// open JMP table
cust = Open( "***\JMP Tables\Customers.jmp");

//connect to DB
SQLConnection = Create database connection("DRIVER=*** SERVER=***; DATABASE=database; Uid=***;Pwd=***");

//Query both
PrePUSQL01 =
"
SELECT
T.CustomerID,
C.Inc
FROM database.dbo.table AS T
JOIN cust AS C ON C.CustomerID = T.CustomerID
WHERE C.Inc = '1'
"　
;
dt = Execute SQL(SQLConnection, 
PrePUSQL01,
"dt"
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Feb 2018 12:09:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51588#M29248</guid>
      <dc:creator>david707</dc:creator>
      <dc:date>2018-02-20T12:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to SQL Query an external database and a saved JMP table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51641#M29286</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I think you might need to do is read in the CustomerID values using GetValues (like in line one below) from the JMP table and then&amp;nbsp;insert that list into the SQL code (using IN operatori for the WHERE clause)..&lt;/P&gt;
&lt;PRE&gt;custIDList = :CustID &amp;lt;&amp;lt; GetValues;&lt;/PRE&gt;
&lt;P&gt;This isn't complete code, but a little push in the right direction.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would have to use a little JSL to insert the list into the SQL code, but at least this would get you only the infromation from the customers that have an ID in the Customer.JMP file. Then you can use Join within JMP to merge the two sets together.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that helps,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chris&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 16:26:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51641#M29286</guid>
      <dc:creator>Chris_Kirchberg</dc:creator>
      <dc:date>2018-02-20T16:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to SQL Query an external database and a saved JMP table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51645#M29290</link>
      <description>&lt;P&gt;Chris is right - you need to create an IN list and include that in your SQL.&amp;nbsp; &lt;A href="https://community.jmp.com/t5/Discussions/JMP-13-JSL-that-passes-variables-to-oracle-SQL-statement/m-p/50692#M28806" target="_self"&gt;This conversation&lt;/A&gt; may be helpful.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 17:00:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51645#M29290</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-02-20T17:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to SQL Query an external database and a saved JMP table?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51674#M29310</link>
      <description>&lt;P&gt;If I'm understanding you correctly, you have a JMP data table with a list of customers and you want to pull rows from a database that match those customers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do this with the &lt;A href="https://www.jmp.com/support/help/13-2/Build_the_SQL_Query.shtml#779214" target="_self"&gt;Match Column Values&lt;/A&gt; filter in Query Builder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JMPScreenSnapz174.png" style="width: 358px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/9410i4D37F9575198689C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JMPScreenSnapz174.png" alt="JMPScreenSnapz174.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;There's an &lt;A href="https://www.jmp.com/support/help/13-2/Build_the_SQL_Query.shtml#623512" target="_self"&gt;example in the documentation&lt;/A&gt; for how to use the Match Columns Filter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 19:18:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-SQL-Query-an-external-database-and-a-saved-JMP-table/m-p/51674#M29310</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2018-02-20T19:18:27Z</dc:date>
    </item>
  </channel>
</rss>

