Andrey Matveev Andrey Matveev - 1 year ago 76
MySQL Question

Selecting points within a bounding square

Help to make a selection from the database (mysql) of the coordinates.There is a table with fields latitude/longitude.The sample should be in the form of a rectangle. Thank you! example

I tried it, but it is necessary in the form of a predetermined size of the rectangle

Answer Source

If you need select the point inside a rectangle is Assuming that your rect have thr coord ($minLat , $minLng , $maxLat, $maxLng) You can simply select the points this way

        select * from my_table 
        point_lat >= $minLat 
        AND point_lat <= $maxLat
        AND point_lng  <= $maxLng
        AND point_lng  >= $minLng;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download