Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
3. Function - ST_Equals
Relationships Between Geometries
ST_Distance and ST_Dwithin
Spatial joins practice


Great job!

The first spatial function we're going to learn about is ST_Equals. As the name suggests, the function simply checks whether two geometries given as arguments are the same geometry—that is, whether they represent the same location or region on a map. Let's look at the example query:

FROM sf_sights ss
JOIN sf_restaurants sep
ON ST_Equals(ss.coordinates, sep.coordinates)

In the above query, we check whether there are geometries worth visiting as eating places (located in the table that contains restaurants) that are also considered to be attractions (they are also present in the sf_sights table).

Notice that we used ST_Equals as a joining condition. This is not your typical join with equality (equi-join). Here, we're using a function to create a join condition. You'll soon see that this type of JOIN is very common in spatial SQL series.


Check whether there is a district in the sf_planning_districts table that is also listed as an attraction in the sf_sights table. Display all data for this district.

Stuck? Here's a hint!

You have to join two tables: sf_planning_districts and sf_sights.