On Aug 28, 2011, at 1:22 PM, Marcelo Pereira wrote:

> I would like to know the distance between "one fixed point" (42.331002 
> -71.112678) and all points in this table.

This is untested but you'd do a self join for this

select p1.longitude, p1.latitude, p2.longitude, p2.latitude, ST_Distance(
                ST_GeomFromText('POINT(' || p1.longitude || ' ' || p1.latitude 
|| ')',4326),
                ST_GeomFromText('POINT(' || p2.longitude || ' ' || p2.latitude 
|| ')',4326)) as distance
from places p1, places p2
where p1.id = p2.id
and p1.id = 1
and p2.id != 1

hth,
charles


_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to