CartoDB: Calculating distance between points in two tables and including the name of

المشرف العام

Administrator
طاقم الإدارة
I am plotting community gardens in CartoDB and want to show the nearest subway entrance in the infowindow. I have two tables with the location of the gardens and the subway stations. I am able to get the closest subway station to each community garden by using the following query:

SELECT nyc_greenthumb_community_gardens_fusion.cartodb_id,MIN(ST_Distance(nyc_subway_entrance_export.the_geom, nyc_greenthumb_community_gardens_fusion.the_geom)) as MinDistanceFROM nyc_subway_entrance_export, nyc_greenthumb_community_gardens_fusionGROUP BY nyc_greenthumb_community_gardens_fusion.cartodb_id

How do I also return the name of the subway station?
It is in the nyc_subway_entrance_export table as nyc_subway_entrance_export.name?
I am assuming that once I have the name of the subway entrance, I can do a join to add the name and distance as new columns in the Community Garden table.

Thanks!



أكثر...
 
أعلى