Is it possible to get just one row/record returned from a feature service query — similar to the TOP, ROWNUM and LIMIT in database queries? Of course, OBJECTID "1" is not guaranteed. Is there a trick that I've missed?
SQL Server / Access: SELECT TOP 1 * FROM CUSTOMERS;
Oracle: SELECT * FROM CUSTOMERS WHERE ROWNUM <= 1;
MySQL: SELECT * FROM CUSTOMERS LIMIT 1;
PostgreSQL: SELECT * FROM CUSTOMERS LIMIT 1;
Best Answer
If you wanna to get only 1 record try use
TOP
statement.ie:
OBJECTID IN (SELECT TOP 1 OBJECTID FROM 'customers' ORDER BY OBJECTID))
but you have note that this is bypass because
TOP
andLIMIT
arent supported by geodatabase http://forums.arcgis.com/threads/68997-TOP-100EDIT I digged deeper cause this subject seems to me as interesting, and I found this kind of script: http://resources.arcgis.com/gallery/file/geoprocessing/details?entryID=E780BB87-1422-2418-7FD8-A1A0D8167AAF it returns a subset of features with the same schema as oryginal. It's made in python so, maybe you could use it as geoprocessing service as gate to your sql queries.
EDIT2 From more research i think that using
TOP
LIMIT
orROWNUM
depends on your DB engine. But the main clue is to use it as subquery - because we only can get access fromWHERE
part of statement by using APINOTE FOR 10.2 USERS: This will not work because it defaults to standardized queries which don't allow subqueries. You can turn off standardized queries, but this is not recommended since it makes SQL injection attacks easier to perform.