<?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: Select/Where Statement Pulls from List in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612525#M81264</link>
    <description>&lt;P&gt;The default character for eval insert is "^".&amp;nbsp; I didn't know you could supply another one.&amp;nbsp; Looks like Jarmo is using&amp;nbsp;&lt;SPAN&gt;¤ for that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To debug:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use print or show to display your SQL statement.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Copy/paste it into a program that can execute directly on your database.&amp;nbsp; For example for Oracle we use PL/SQL Developer, TOAD or SQL Developer&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have that working, run it from JMP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's some sample code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// List of numeric IDs
id_list = {111, 222, 333, 444, 555};

// Convert numbers to text
for (i = 1, i &amp;lt;= nitems(id_list), i++,
	id_list[i] = char(id_list[i]);
);

in_list = "('" || concat items(id_list, "', '") || "')";
show(in_list);

sql_statement = evalinsert(
"SELECT * from mytable m
  WHERE m.id IN 
^in_list^"
);

show(sql_statement);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try running this and look for the results in the log window.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2023 14:28:28 GMT</pubDate>
    <dc:creator>pmroz</dc:creator>
    <dc:date>2023-03-15T14:28:28Z</dc:date>
    <item>
      <title>Select/Where Statement Pulls from List</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612025#M81227</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure if the title describes this issue the best, but I feel like I am on the verge of getting this figured out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one JMP table with a column TestID and I want to select rows from another data table based on the variable TestID list.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open("Lot List2.jmp");

ID_list = Column( dt, "TestID" ) &amp;lt;&amp;lt; Get values;

dt1= Open Database("Connection",
"SELECT
[TestID]
,[Device]
,[FailureMode]
FROM [Database]

where TestID IN 'ID_list'

order by [TestID] Desc","Device Summary");&lt;BR /&gt;&lt;BR /&gt;/* ALSO TRIED*/&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;dt = Open("Lot List2.jmp");

ID_list = Column( dt, "TestID" ) &amp;lt;&amp;lt; Get values;

dt1= Open Database("Connection",
"SELECT
[TestID]
,[Device]
,[FailureMode]
FROM [Database] m

where m.TestID like 'ID_list'

order by [TestID] Desc","Device Summary");&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My issue lies somewhere in my 'where' statement, but I am not sure how to call the string of IDs into this statement. The IN statement option does not open a new table, and the like option opens a blank table. My guess is that it treats ID_list as the variable to look for in the other table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found a similar question, but the IN statement is not working for me either:&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/how-to-extract-data-with-criteria-of-JMP-table-values/td-p/9434" target="_blank" rel="noopener"&gt;https://community.jmp.com/t5/Discussions/how-to-extract-data-with-criteria-of-JMP-table-values/td-p/9434&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any insights are appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:29:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612025#M81227</guid>
      <dc:creator>SampleIguana839</dc:creator>
      <dc:date>2023-06-08T16:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Select/Where Statement Pulls from List</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612136#M81236</link>
      <description>&lt;P&gt;ID_list will return you a list of strings (or numbers) and you will have to convert it into a string that SQL query will understand and then add that string to your query. Below is one example of query building using Concat Items and Eval Insert&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

ID_list = Column(dt, "name") &amp;lt;&amp;lt; Get values; // list of strings?

sql_template = "SELECT [TestID], [Device], [FailureMode]
FROM [Database]
where TestID IN ('¤idlist_sql¤')
order by [TestID] Desc";

idlist_sql = Concat Items(ID_list, "','");

sql_str = Eval Insert(sql_template, "¤");
	
dt1 = Open Database("Connection",
	sql_str
	"Device Summary"
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This presentation might give some additional ideas&lt;LI-MESSAGE title="JMP and Oracle: Tips and Tricks for a Happy Marriage (2022-US-30MP-1093)" uid="505583" url="https://community.jmp.com/t5/Discovery-Summit-Americas-2022/JMP-and-Oracle-Tips-and-Tricks-for-a-Happy-Marriage-2022-US-30MP/m-p/505583#U505583" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 06:55:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612136#M81236</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-15T06:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select/Where Statement Pulls from List</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612480#M81259</link>
      <description>&lt;P&gt;Oh okay I see the modifications you have to do. I have used this template, but I am still note getting another data table to appear. what is this symbol, ¤ ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 13:49:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612480#M81259</guid>
      <dc:creator>SampleIguana839</dc:creator>
      <dc:date>2023-03-15T13:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Select/Where Statement Pulls from List</title>
      <link>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612525#M81264</link>
      <description>&lt;P&gt;The default character for eval insert is "^".&amp;nbsp; I didn't know you could supply another one.&amp;nbsp; Looks like Jarmo is using&amp;nbsp;&lt;SPAN&gt;¤ for that.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To debug:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Use print or show to display your SQL statement.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Copy/paste it into a program that can execute directly on your database.&amp;nbsp; For example for Oracle we use PL/SQL Developer, TOAD or SQL Developer&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have that working, run it from JMP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's some sample code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// List of numeric IDs
id_list = {111, 222, 333, 444, 555};

// Convert numbers to text
for (i = 1, i &amp;lt;= nitems(id_list), i++,
	id_list[i] = char(id_list[i]);
);

in_list = "('" || concat items(id_list, "', '") || "')";
show(in_list);

sql_statement = evalinsert(
"SELECT * from mytable m
  WHERE m.id IN 
^in_list^"
);

show(sql_statement);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try running this and look for the results in the log window.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 14:28:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Select-Where-Statement-Pulls-from-List/m-p/612525#M81264</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2023-03-15T14:28:28Z</dc:date>
    </item>
  </channel>
</rss>

