Following query will find records which came under 1.5 km on the basis of user current latitude and longitude
user latitude is 21.153518
user latitude is 79.045513
SELECT *
FROM users
WHERE ( 3959 * ACOS( COS( RADIANS( 21.153518 ) ) * COS( RADIANS( users.latitude ) ) * COS( RADIANS( users.longitude ) - RADIANS( 79.045513 ) ) + SIN( RADIANS( 21.153518) ) * SIN( RADIANS( users.latitude ) ) ) ) < 1.5
Here is some more query may be helpful to you guys :)
SELECT users. * ,ACOS( SIN( RADIANS( users.`latitude` ) ) * SIN( RADIANS( 21.153518 ) ) + COS( RADIANS( users.`longitude` ) ) * COS( RADIANS( 21.153518 ) ) * COS( RADIANS( users.`longitude` ) - RADIANS( 79.045513 ) ) ) *6380 FROM users
SELECT * , ( 3959 * ACOS( COS( RADIANS( 21.153518 ) ) * COS( RADIANS( users.latitude ) ) * COS( RADIANS( users.longitude ) - RADIANS( 79.045513 ) ) + SIN( RADIANS( 21.153518) ) * SIN( RADIANS( users.latitude ) ) ) ) AS distance
FROM users
ORDER BY distance
user latitude is 21.153518
user latitude is 79.045513
SELECT *
FROM users
WHERE ( 3959 * ACOS( COS( RADIANS( 21.153518 ) ) * COS( RADIANS( users.latitude ) ) * COS( RADIANS( users.longitude ) - RADIANS( 79.045513 ) ) + SIN( RADIANS( 21.153518) ) * SIN( RADIANS( users.latitude ) ) ) ) < 1.5
Here is some more query may be helpful to you guys :)
SELECT users. * ,ACOS( SIN( RADIANS( users.`latitude` ) ) * SIN( RADIANS( 21.153518 ) ) + COS( RADIANS( users.`longitude` ) ) * COS( RADIANS( 21.153518 ) ) * COS( RADIANS( users.`longitude` ) - RADIANS( 79.045513 ) ) ) *6380 FROM users
SELECT * , ( 3959 * ACOS( COS( RADIANS( 21.153518 ) ) * COS( RADIANS( users.latitude ) ) * COS( RADIANS( users.longitude ) - RADIANS( 79.045513 ) ) + SIN( RADIANS( 21.153518) ) * SIN( RADIANS( users.latitude ) ) ) ) AS distance
FROM users
ORDER BY distance