Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

radius search with point data in mysql

SELECT id, 
( 6371 * 
    ACOS( 
        COS( RADIANS( db_latitude ) ) * 
        COS( RADIANS( $user_latitude ) ) * 
        COS( RADIANS( $user_longitude ) - 
        RADIANS( db_longitude ) ) + 
        SIN( RADIANS( db_latitude ) ) * 
        SIN( RADIANS( $user_latitude) ) 
    ) 
) 
AS distance FROM the_table HAVING distance <= $the_radius ORDER BY distance ASC"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #radius #search #point #data #mysql
ADD COMMENT
Topic
Name
9+3 =