I have two tables, one with "houses", and the other with "points". I know how to get the distance individually, like this:
gisdb=# SELECT round(ST_Distance_Sphere( (SELECT coordinates FROM houses WHERE id = 1), (SELECT coordinates FROM points WHERE id = 2))) as Distance ; distance ---------- 174 (1 row)
The thing is, if on the table "points" I have about 50 points, how can I make it return the distance of the closest one?
I've seen the function
ST_ClosestPoint but I don't know how to apply it to my query.