Hi,
I am very new to ArcGIS and have "inherited" a project that provides a map on one of our web pages. I am slogging through it and learning a lot, but one thing still stumps me. This code has several instances where it sets the Query 'where' property to '1=0'. Now, to my SQL thinking, adding a where clause such as 1=0, which evaluates to false, would return nothing. However, I have witnessed that something does get returned when I enter the corresponding URL (like the one below). If I change the where to '1=1' much more data is returned, however.
Can anyone please explain the purpose of using a where clause of '1=0'?
https://<URL Returning FeatureLayer>/query?f=json&where=1=0
I'm not sure why someone would want that, I suppose it depends. The query would return info about the fields, maybe some other service info, but an empty array of features.
Since there's not really a true boolean value in SQL, people use 1=0 or 1=1. You would use 1=0 in some geoprocessing tools (like feature class to feature class) to copy the table structure without the data. Although you can do the same thing using the template parameter with Create Table or Create Feature Class. In the context of a JS web app, I'm not really sure why you would query where 1=0. I'd have to see it in context.
Using 1=1 will return all rows and is common in web apps when querying a feature layer in order to work with all the data.
One of the scenarios where this is used is when populating an OnDemandGrid. After the grid is populated during initialization, there is an icon placed on the map to display the grid.
It may be that the first query (with 1=0) is used to just initialize the grid with nothing. Later in the initialization process, the query is re-issued (with 1=1) to retrieve data and populate the grid. I don't know, yet, but there may be scenarios where the query is never re-issued during initialization. In that case, if we hadn't already initialized the grid, nothing would show at all.