Search for Features Using SQL Queries


Returns features in a named table in the repository based on a MapInfo SQL query. See the MapInfo SQL Language Reference for detailed information about MI SQL functions.

Note: All MapInfo SQL functions are supported except the MI_GridMinValue and MI_GridMaxValue grid functions.

This operation returns a feature collection JSON that can be passed to a render map or render legend request in the Mapping service.

ACL Authorization Flow

To return features in a named table in the repository based on a MapInfo SQL query, the user (or the role they belong to) needs EXECUTE permission on the Named table.

Note: If the SQL query references more than one table, then EXECUTE permissions are needed on all of the tables included in the query.


For information about the parameter types listed below, see Request URL Data Types.

rep String yes The representation to be returned. Supported representation is json.
q=MI SQL query String yes

The query to perform in MI SQL format. The query statement can also be specified in the POST body instead. For details, see HTTP POST URL Format.

page=pagenumberString no The page number to return.
pageLength=pagelength String no The number of features returned on each page. If the page parameter is specified in the request, you must define pageLength.


The following format is used for HTTP GET requests:

HTTP GET /tables/features.rep;[q=SQL query]


Returns specified features in a named table in the repository.



Returns the features for the records where the country is CANADA for the table WorldTable located in the /Samples/NamedTables directory in the Repository.

http://hostname:port/rest/Spatial/FeatureService/tables/features.json?q=SELECT * FROM 
"/Samples/NamedTables/WorldTable" WHERE Country='CANADA'


The following format is used for HTTP POST requests to Search by SQL using query and bound parameters:

POST: /FeatureService/tables/features.rep?
POST Data: [q=MI SQL query]
POST BODY: Content-Type:application/json {query, bound parameters} 

The {bound parameters} is part of a POST json body (Content-Type: application/json) for the MI SQL search query containing one or multiple parameters to be included. Null values are supported; however, a type is still required.

The query allows specifying a query statement in the POST body in addition to the q parameter in URL. This is useful when the query statement is very long that may extend the size limitation of an URL. When both q and query are specified in the body of the request, then only q is used.

Note: The json in the POST is optional; it is only required if the SQL query uses bound parameters.


Returns specified features in a named table in the repository.


Search for features using bound and query parameters:

   "query":"SELECT WORLD.Capital, WORLD.Country FROM \"/Samples/NamedTables/WorldTable\" WORLD WHERE MI_Contains(Obj,@geomParam)",

Search for features using bound parameters for a parameterized view (a view table that contains bind parameters):

    "query":"SELECT Country, Capital FROM \"/NamedTables/ViewTableWithParameters\"",
	"parameters": [
			"name": "param", 
			"value": [
				"United States", "Canada", "France", "Germany"
			"type": "String"
Note: Parameters defined as part of the request override the bind parameters within a view table. The response contains the candidates specified as parameters in the request. If the parameters specified as part of the request (such as “name”:”param”) do not match the parameters defined as part of the view table, then the default bind parameters defining part of the view table are used. A named table (not a view table or without bind parameters) could include bind parameters within the request. In this case, you can pass bind parameters for the query is part of the request.