I'm trying to write a SQL query that takes values from two inputs. Below is what I have so far:
queryParcels.where = "PARID LIKE '" + "%" + dom.byId("parcelText").value + "'" + " OR ADDR LIKE '" + "%" + dom.byId("addrText").value + "'";The query executes fine but the issue I am having is when one of inputs is left empty. When this occurs, the query that's sent to the server has '%' in it which returns the maximum amount of records from the server. Even if I leave the wildcards out, I get similar results. For example, below are the the query string parameters when I enter a value for the parcel number, but leave the address value empty:
- f:json
- where:PARID LIKE '%6760621' OR ADDR LIKE '%'
- returnGeometry:true
- spatialRel:esriSpatialRelIntersects
- outFields:PARID,ADDR,OBJECTID
- outSR:102100
Is there a way to insert NULL into the where clause if an input is left empty?