<?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: SQL query using the Label in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590910#M86835</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Can you please help me out with the example&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Mon, 27 May 2024 11:54:20 GMT</pubDate>
    <dc:creator>selvantamil674</dc:creator>
    <dc:date>2024-05-27T11:54:20Z</dc:date>
    <item>
      <title>SQL query using the Label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590908#M86833</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 23.1.1 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;I am trying to query a GlobalTable1 using SQL, but the column name is present in token.col in the token, how to access the token.col value in the sql query&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 May 2024 11:37:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590908#M86833</guid>
      <dc:creator>selvantamil674</dc:creator>
      <dc:date>2024-05-27T11:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query using the Label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590909#M86834</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Concatenate the label value and the query string.&lt;/P&gt;&lt;PRE&gt;"SELECT [" + token.col + "] FROM tableName WHERE..."&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 May 2024 11:46:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590909#M86834</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2024-05-27T11:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query using the Label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590910#M86835</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Can you please help me out with the example&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 May 2024 11:54:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590910#M86835</guid>
      <dc:creator>selvantamil674</dc:creator>
      <dc:date>2024-05-27T11:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query using the Label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590911#M86836</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;What is unclear about the example I provided? You type your query as you would normally until you would enter the column name. You then end the string, add the column name to it with ' + token.col', then you add the the rest of the query as a string again ( + "...").&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 May 2024 12:37:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590911#M86836</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2024-05-27T12:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query using the Label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590912#M86837</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Yeah it working fine Thanks for the Answer, Now, I just need to Query two column in WHERE which matches the value, can you please help out in this, i am attaching the file with this&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/83192-fetch-table-using-token-and-sql.fsm" target="_blank"&gt;Fetch_Table_using_Token_and_SQL.fsm&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 May 2024 06:11:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590912#M86837</guid>
      <dc:creator>selvantamil674</dc:creator>
      <dc:date>2024-05-28T06:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query using the Label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590913#M86838</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;- The label on the token is called "Name", not "Col"&lt;/P&gt;&lt;P&gt;- When comparing a column to a string value, the string needs to be enclosed in single quotation marks within the query (WHERE [Name] == 'A'), so you need to add those to the query string in front of and after the label value.&lt;/P&gt;&lt;P&gt;- You need to convert the number value from "token.Num" to a string before you can insert it into the query like this (string.fromNum(token.Num))&lt;/P&gt;&lt;P&gt;- You only write WHERE once, then write multiple checks separated by AND or OR&lt;/P&gt;&lt;PRE&gt;Table result = Table.query("SELECT * FROM Test1 \&lt;BR /&gt;&amp;nbsp; &amp;nbsp; WHERE [Name] = '"+token.Name+"' AND [Num] = "+string.fromNum(token.Num)+"");&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;With all that said, values that you want to compare columns to can more easily be passed in via the $-syntax. Inserting the label directly into the string is only needed if it represents a column name or SQL clause.&lt;/P&gt;&lt;PRE&gt;Table result = Table.query("SELECT * FROM Test1 WHERE [Name] = $1 AND [Num] = $2", token.Name, token.Num);&lt;/PRE&gt;&lt;P&gt;When the query is run, $1 will be replaced by the first value that is passed in after the query, $2 by the second and so on.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 May 2024 07:25:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590913#M86838</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2024-05-28T07:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query using the Label</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590914#M86839</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Thanks for the Answer
&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 May 2024 07:52:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/sql-query-using-the-label/m-p/13590914#M86839</guid>
      <dc:creator>selvantamil674</dc:creator>
      <dc:date>2024-05-28T07:52:17Z</dc:date>
    </item>
  </channel>
</rss>

