AnsweredAssumed Answered

SQL Query Question

Question asked by rcsellman on Dec 30, 2014
Latest reply on Dec 30, 2014 by rcsellman

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:

 

  1. f:json
  2. where:PARID LIKE '%6760621' OR ADDR LIKE '%'
  3. returnGeometry:true
  4. spatialRel:esriSpatialRelIntersects
  5. outFields:PARID,ADDR,OBJECTID
  6. outSR:102100

 

 

 

 

 

Is there a way to insert NULL into the where clause if an input is left empty?

 

 

Outcomes