Product affected: MapInfo Pro™
Here are the steps to querying for point objects found within polygon or region objects in MapInfo Pro.
1. Here is a table of point objects representing banks and table of region or polygon objects (States) in the United States.
2. In MapInfo Pro 64-bit, go to Spatial > Selection > SQL Select.
3. Fill out the SQL Select Dialog box like this:
First, in the "from Tables" option, select the points table from the "Tables" drop-down and then select the polygon table.
The Points table is selected first in the query because the goal is to return the Point objects that fall within the polygon objects.
In the "Where Condition" a "Within" or "Contains" operator is used, as this type of join is called a "geographical join" where the relationship is defined by the spatial location of objects as opposed to a "columnar" join, where a common filed of column can join the 2 tables, such as ID, etc.
The Where condition "SavingsNLoan.Obj Within USA.Obj" is a query to find the point objects (.obj) from the SavingsNLoan table that are located within the polygon "State" objects.
The "Select Columns" by default has an asterisk (*). This symbol means that all fields from both tables will be in the new query.
To change this, delete the asterisk and add the column(s) needed using the "Columns" drop down on the right.
Additionally, there are the optional "Group by" and "Order by" fields in the dialog.
The "Group by" option groups records by a designated column.
If the State_Name field was chosen, for example, then all the point objects for each state would be queried together and Count field could return a Count of all point objects in a given State (example: New York). The "Group By" field is a great way to get a count of the number of points within a polygon.
Note: when using the "Group by" option, the resultant query will not have map objects and Pro is working as designed.
The "Order By" option allows Pro users to sort based on a chosen field.
Once the SQL Dialog is filled out, click Verify. If the query has no errors, "Syntax is Correct" will display. Then click OK to run the query.
When the query is run, a table of points objects, including the State in which they are located they are found, will be returned.
This resultant query can be exported to Excel as a .csv, saved as a native tab format file, etc..
UPDATED: December 2, 2019