<?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: Query.where clause is a SQL language? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-where-clause-is-a-sql-language/m-p/139882#M12999</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like there is a text parameter on queries to a MapServer, it's mentioned in the&amp;nbsp;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/#/Query_Map_Service_Layer/02r3000000p1000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;REST API documentation&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will search for matches with the layer's display field, which happens to be STATE_NAME in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use where instead, you could do this similar to how&amp;nbsp;you indicated. &amp;nbsp;You do need to wrap the value in&amp;nbsp;single quotes. &amp;nbsp;Another option is to use the new JavaScript template strings to make this easier. &amp;nbsp;Note this uses backticks (`) as string delimiters:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;query&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;where &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"STATE_NAME = '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; dom&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;byId&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"stateName"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍
&lt;SPAN class="comment token"&gt;// OR&lt;/SPAN&gt;
query&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;where &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; `STATE_NAME &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'${dom.byId("stateName").value}'&lt;/SPAN&gt;`&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can have multiple clauses separated by AND or OR. &amp;nbsp;I'm not sure where to find documentation about the SQL syntax that is accepted, although I seem to recall it being somewhere in the REST API documentation. &amp;nbsp;It can be quite difficult to find useful information there to be honest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:43:19 GMT</pubDate>
    <dc:creator>ThomasSolow</dc:creator>
    <dc:date>2021-12-11T07:43:19Z</dc:date>
    <item>
      <title>Query.where clause is a SQL language?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-where-clause-is-a-sql-language/m-p/139881#M12998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am very confused about the Line 31, where clause&amp;nbsp;is like below (ESRI JS API sample code):&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=query_nomap" title="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=query_nomap" rel="nofollow noopener noreferrer" target="_blank"&gt;query.where clause Sandbox&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The one that is used on Line 31 -- query.text = dom.byId("stateName").value;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My quesion is: how can it know the ("stateName").value is compared to STATE_NAME, not other variable? &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second question is that: &amp;nbsp;I would like to use &amp;nbsp;--- &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;query.where ="STATE_NAME = &amp;nbsp;stateName.value"; &amp;nbsp;but it does not work at all;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know it should be:&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;query.where ="STATE_NAME = '" + dom.byId ("stateName.value") + "'";&amp;nbsp;&lt;/P&gt;&lt;P&gt;But why the clause should be like that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another question is what should I go to study the grammar of query.where clause? SQL? The statement like below is too confusing:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #000000;"&gt;query&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000088;"&gt;where&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;"POP04 &amp;gt; "&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; population&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #000000;"&gt;query&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000088;"&gt;where&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;"NAME = '"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; stateName &lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;+&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666600;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #000000;"&gt; 

Thanks!&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:43:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-where-clause-is-a-sql-language/m-p/139881#M12998</guid>
      <dc:creator>LindaM</dc:creator>
      <dc:date>2021-12-11T07:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Query.where clause is a SQL language?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-where-clause-is-a-sql-language/m-p/139882#M12999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like there is a text parameter on queries to a MapServer, it's mentioned in the&amp;nbsp;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/#/Query_Map_Service_Layer/02r3000000p1000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;REST API documentation&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will search for matches with the layer's display field, which happens to be STATE_NAME in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To use where instead, you could do this similar to how&amp;nbsp;you indicated. &amp;nbsp;You do need to wrap the value in&amp;nbsp;single quotes. &amp;nbsp;Another option is to use the new JavaScript template strings to make this easier. &amp;nbsp;Note this uses backticks (`) as string delimiters:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;query&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;where &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"STATE_NAME = '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; dom&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;byId&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"stateName"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;value &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍
&lt;SPAN class="comment token"&gt;// OR&lt;/SPAN&gt;
query&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;where &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; `STATE_NAME &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'${dom.byId("stateName").value}'&lt;/SPAN&gt;`&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can have multiple clauses separated by AND or OR. &amp;nbsp;I'm not sure where to find documentation about the SQL syntax that is accepted, although I seem to recall it being somewhere in the REST API documentation. &amp;nbsp;It can be quite difficult to find useful information there to be honest.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:43:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-where-clause-is-a-sql-language/m-p/139882#M12999</guid>
      <dc:creator>ThomasSolow</dc:creator>
      <dc:date>2021-12-11T07:43:19Z</dc:date>
    </item>
  </channel>
</rss>

