SELECT * , 3956 *2 * ASIN( SQRT( POWER( SIN( ( 122.4058 - ABS( dest.lat ) ) * PI( ) /180 /2 ) , 2 ) + COS( 122.4058 * PI( ) /180 ) * COS( ABS( dest.lat ) * PI( ) /180 ) * POWER( SIN( ( 37.7907 - dest.lon ) * PI( ) /180 /2 ) , 2 ) ) ) AS distance
FROM members dest
HAVING distance <25
Above query run perfectly .. Users will have one field name search_distance .. So i want to calculate users location and current location distance based in search_distance too..
Please help me to solve this ! Let me know if this is not clear
User Table have below fields
id, user_name, lat, lon, search_distance