Re: SQL Average Function to create a central point
I dunno what version of SQL you are using but if it's mysql and your
webserver is >= version 4.1 I would suggest using geospatial
extensions.
This would enable you to store a point (ie both lat and lng) in one
field or even a line or a polygon (multiple lat, lngs).
You can then do various useful stuff like
SELECT * FROM locations WHERE point WITHIN (GEOMFROMTEXT(0 0,0 1,1 1,1
0));
to select all points within a certain area.
Some flavours of SQL will perform functions such as returning centoids
like you want for this problem.
You do not loose the ability to select based upon lat or long -
accessing the individual lat and long from a feild such as this is
easy:
SELECT *, X(point) AS lat, Y(point) AS lng FROM locations ....
0 Comments:
Yorum Gönder
<< Home