<?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: Where clause syntax using field name coming from a join, setting a variable in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/where-clause-syntax-using-field-name-coming-from-a/m-p/758880#M70248</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got it to work.&amp;nbsp; I had to add quotes as a string around the field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var distFieldPath = "MCDS_DATAWAREHOUSE.EDAPPGISSCHLDIRT.%SCHOOL_DIRECTORY_DISTRICT";
var fieldName = distFieldPath + ".DCOUNTY";
var whereClause = ' " ' + fieldName + ' " ' + " LIKE '%" + currentCounty + "%'";&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 08:10:44 GMT</pubDate>
    <dc:creator>TracySchloss</dc:creator>
    <dc:date>2021-12-12T08:10:44Z</dc:date>
    <item>
      <title>Where clause syntax using field name coming from a join, setting a variable</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/where-clause-syntax-using-field-name-coming-from-a/m-p/758879#M70247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is for the where clause of a FeatureLayer.selectFeatures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used a variable for a field name, but this is the first time I've tried to get this to work with a field name coming from a join to a SQL Server database table.&amp;nbsp; I know the single quote/double quote looks strange, but hard coded, this is the only way it works.&amp;nbsp;&amp;nbsp; I assume this is because the field names from the join&amp;nbsp; contain %, so I needed to surround the field name with extra punctuation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I started off with this and it works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var whereClause = '"MCDS_DATAWAREHOUSE.EDAPPGISSCHLDIRT.%SCHOOL_DIRECTORY_DISTRICT.DCOUNTY"' + " LIKE '%" + currentCounty + "%'"; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The database is different from test to production and I need to set some variables instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var countyFieldName = "MCDS_DATAWAREHOUSE.EDAPPGISSCHLDIRT.%SCHOOL_DIRECTORY_DISTRICT.DCOUNTY";
var whereClause = countyFieldName + " LIKE '%" + currentCounty + "%'"; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This doesn't work.&amp;nbsp; When you put in a breakpoint, the syntax looks OK.&amp;nbsp; I'm using LIKE because DCOUNTY has trailing blanks in it and I have no control over this agency's database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would actually prefer to just set the variable as MCDS_DATAWAREHOUSE.EDAPPGISSCHLDIRT.%SCHOOL_DIRECTORY_DISTRICT, which is the database name and just concatenate the field names.&amp;nbsp;&amp;nbsp; I have this set earlier for my infoTemplates.&amp;nbsp; I couldn't wrap my head around this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var distFieldPath = "MCDS_DATAWAREHOUSE.EDAPPGISSCHLDIRT.%SCHOOL_DIRECTORY_DISTRICT";
var whereClause = distFieldName + ".DCOUNTY LIKE '%" + currentCounty + "%'";&amp;nbsp; &lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That's not quite right, because I need to punctuate the field name.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:10:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/where-clause-syntax-using-field-name-coming-from-a/m-p/758879#M70247</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2021-12-12T08:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause syntax using field name coming from a join, setting a variable</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/where-clause-syntax-using-field-name-coming-from-a/m-p/758880#M70248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got it to work.&amp;nbsp; I had to add quotes as a string around the field name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var distFieldPath = "MCDS_DATAWAREHOUSE.EDAPPGISSCHLDIRT.%SCHOOL_DIRECTORY_DISTRICT";
var fieldName = distFieldPath + ".DCOUNTY";
var whereClause = ' " ' + fieldName + ' " ' + " LIKE '%" + currentCounty + "%'";&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:10:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/where-clause-syntax-using-field-name-coming-from-a/m-p/758880#M70248</guid>
      <dc:creator>TracySchloss</dc:creator>
      <dc:date>2021-12-12T08:10:44Z</dc:date>
    </item>
  </channel>
</rss>

