<?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: Reference Table file name in SQL query in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Reference-Table-file-name-in-SQL-query/m-p/254261#M49918</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/17878"&gt;@Jackie_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;For others following along, one of the best teachers for writing JSL using JMP is to first perform the steps interactively and then ask JMP to write the script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to suggest watching some instructional videos using JMP Query Builder from our online series&amp;nbsp;&lt;A title="JMP Mastering: Query Builder" href="https://www.jmp.com/en_gb/events/ondemand/mastering-jmp/accessing-databases.html" target="_self"&gt;Mastering JMP.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Additional tutorials on data wrangling using&amp;nbsp;&lt;A title="Discovery Summit JMP Query Builder " href="https://community.jmp.com/t5/Discovery-Summit-2016/Wrangling-All-Your-Data-With-Query-Builder-in-JMP-13-Developer/ta-p/24143" target="_self"&gt;JMP Query Builder from our Discovery Summit Series&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To extend the join amongst additional tables the general process is the same as previously shown with two tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cheers,&lt;/P&gt;
&lt;P&gt;Stan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Mar 2020 16:24:01 GMT</pubDate>
    <dc:creator>stan_koprowski</dc:creator>
    <dc:date>2020-03-25T16:24:01Z</dc:date>
    <item>
      <title>Reference Table file name in SQL query</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-Table-file-name-in-SQL-query/m-p/254183#M49897</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/706"&gt;@stan_koprowski&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used JMP Query Builder to create the following SQL Query&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
//Prompt to select and open an MS Excel file
dt1 = Open( Pick File( "Select Excel File", "$DOCUMENTS", {"Excel Files|csv;xlsx;xls", "All Files|*"}, 1, 0 ), Invisible );

//Prompt to select an open a JMP data table
dt2 = Open( Pick File( "Select JMP File", "$DOCUMENTS", {"JMP Files|jmp", "All Files|*"}, 1, 0 ), Invisible );

//Perform a left outer join on the tables using the "Name" Column
New SQL Query(
	Version( 130 ),
	Connection( "JMP" ),
	JMP Tables(
		["1st_file" =&amp;gt;
		"Source(Open( \!"dt1\!",
	Worksheets( \!"worksheet\!" ),
	Use for all sheets( 1 ),
	Concatenate Worksheets( 0 ),
	Create Concatenation Column( 0 ),
	Worksheet Settings(
		1,
		Has Column Headers( 1 ),
		Number of Rows in Headers( 1 ),
		Headers Start on Row( 1 ),
		Data Starts on Row( 2 ),
		Data Starts on Column( 1 ),
		Data Ends on Row( 0 ),
		Data Ends on Column( 0 ),
		Replicated Spanned Rows( 1 ),
		Replicated Spanned Headers( 0 ),
		Suppress Hidden Rows( 1 ),
		Suppress Hidden Columns( 1 ),
		Suppress Empty Columns( 1 ),
		Treat as Hierarchy( 1 ),
		Multiple Series Stack( 0 ),
		Import Cell Colors( 0 ),
		Limit Column Detect( 0 ),
		Column Separator String( \!"-\!" )
	)
))",
		"2nd_file" =&amp;gt; "Source(Open( \!"dt2\!"))"]
	),
	QueryName( "Data_Blending" ),
	Select(
		Column( "Name", "t2" ),
		Column( "Enable", "t2" ),
		Column( "Type", "t2" ),
		Column( "Phase", "t2" ),
		Column( "Values", "t3" )
	),
	From(
		Table( "2nd_file", Alias( "t2" ) ),
		Table(
			"1st_file",
			Alias( "t3" ),
			Join(
				Type( Left Outer ),
				EQ( Column( "Name", "t2" ), Column( "Name", "t3" ) )
			)
		)
	)
) &amp;lt;&amp;lt; Run;

//Close source files without saving
Close(dt1, "NoSave");
Close(dt2, "NoSave") &lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;The above script will perform Left Join.&lt;/LI&gt;&lt;LI&gt;More specifically it will copy the "Values" Column from 2nd file into 1st file and creates Data_Blending JMP Table.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above script works only if the file name is entered in the Query.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What if I want to run the same script on different files without changing the Reference Table name ?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Let's my 2nd file name remains constant and I want to perform similar operations on different files.&lt;/P&gt;&lt;P&gt;I have another excel file "3rd_file" and I don't want to change the name in the Query. Is there any Syntax which can copy the file name in the red circle part of the following image?&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="Jacksmith12_0-1585076254812.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/22553i7D44D7B319DD1D2D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jacksmith12_0-1585076254812.png" alt="Jacksmith12_0-1585076254812.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any help/guidance is appreciated.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:26:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-Table-file-name-in-SQL-query/m-p/254183#M49897</guid>
      <dc:creator>Jackie_</dc:creator>
      <dc:date>2023-06-09T23:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Reference Table file name in SQL query</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-Table-file-name-in-SQL-query/m-p/254261#M49918</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/17878"&gt;@Jackie_&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;For others following along, one of the best teachers for writing JSL using JMP is to first perform the steps interactively and then ask JMP to write the script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to suggest watching some instructional videos using JMP Query Builder from our online series&amp;nbsp;&lt;A title="JMP Mastering: Query Builder" href="https://www.jmp.com/en_gb/events/ondemand/mastering-jmp/accessing-databases.html" target="_self"&gt;Mastering JMP.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Additional tutorials on data wrangling using&amp;nbsp;&lt;A title="Discovery Summit JMP Query Builder " href="https://community.jmp.com/t5/Discovery-Summit-2016/Wrangling-All-Your-Data-With-Query-Builder-in-JMP-13-Developer/ta-p/24143" target="_self"&gt;JMP Query Builder from our Discovery Summit Series&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To extend the join amongst additional tables the general process is the same as previously shown with two tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cheers,&lt;/P&gt;
&lt;P&gt;Stan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 16:24:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-Table-file-name-in-SQL-query/m-p/254261#M49918</guid>
      <dc:creator>stan_koprowski</dc:creator>
      <dc:date>2020-03-25T16:24:01Z</dc:date>
    </item>
  </channel>
</rss>

