English

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

Question

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

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.

Related Information