Query REST service with NULL values

7923
4
07-26-2011 07:57 AM
WadeGivens
New Contributor II
Hope this is the right forum for this question.  I have a Map Service that I am trying to query at the REST endpoint on the server.  In the "Where:" field I have (CropName = 'SOY') AND (IrrigationName Like '%') as my query, which returns 3 results.  The problem is there are 10 records that match this query, with 7 of the records having 'NULL' as the value for IrrigationName.  Any reason why the query I'm using is not picking up these 7 records as well?

Thanks,
Wade Givens
4 Replies
ar4
by
New Contributor
Wade

Does that query return the expected results if fired directly at the database ?

What are you expecting? I think by putting in a LIKE you are actually saying

"Where field value is anything except null"
0 Kudos
SrinivasVinnakota
Esri Contributor
Does IrrigationName contains 'NULL' string or database <NULL> values? If former what you pass in should work. If it is the latter then you should use IS NULL or IS NOT NULL sql clauses to work with <NULL> values.

If you are interested in retrieving all records irrespective of IrrigationName value then why do you specify this field in the where clause?
WadeGivens
New Contributor II
Wade

Does that query return the expected results if fired directly at the database ?

What are you expecting? I think by putting in a LIKE you are actually saying

"Where field value is anything except null"


That was it exactly what the problem was.  Had to modify query to include (CropName = 'SOY') AND (IrrigationName Like '%') OR (IrrigationName Is Null)
0 Kudos
ar4
by
New Contributor
Glad to see you got it working
0 Kudos