Whoa! It looks like Mark has tons of routes to choose from. However, remember that if one of the geometries is entirely inside the other,
FALSE. To check whether a geometry is entirely inside another one, we can use the
ST_Within function, like so:
ST_Within function checks whether geometryA. is entirely inside geometryB. The order of the arguments matters here. If we reverse them such that geometryB comes first, then the function will return
TRUE if geometryB is contained entirely within the space that geometryA occupies.
Take a look at an example query that relies on this function:
FROM sf_atms sa
JOIN sf_planning_districts spd
ON ST_Within(sa.coordinates, spd.boundaries)
WHERE spd.name = 'Downtown'
The query above lists all the ATMs that are located within the Downtown district. As you see, the database engine treats spatial joins just like any other type of join. This means we can also add additional clauses to our queries, such as
GROUP BY, and so on.