Frequently asked question

Is it possible to use the LIKE parser in a JavaScript query?

Last Published: April 25, 2020

Answer

The query.where clause allows any legal SQL WHERE clause operating on the fields in a layer. By using the '=' (equal sign) operator, the clause searches for exact results, in comparison to the LIKE operator that searches for a pattern or results containing part of the specified query request.

The following code snippet demonstrates how the LIKE query is used in an SQL expression:
query.where = "ID LIKE ' '%123%'"
The query searches for IDs containing the value, 123. The code snippet below demonstrates how the WHERE clause is used to produce a similar result, for specific data according to the desired classification:
var input = dom.byId("ID").value 
var inputID = input.toUpperCase(); 
query.where = "ID = '123'"
Note:
It is crucial to set the query object's WHERE clause correctly and use the '=' operator in the query statement to perform an exact match.

Article ID:000014290

Software:
  • ArcGIS API for JavaScript 4 x
  • ArcGIS API for JavaScript 3 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic