$query = sprintf("SELECT user_id, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM bid_latlng HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
mysql_real_escape_string($center_lat),
mysql_real_escape_string($center_lng),
mysql_real_escape_string($center_lat),
mysql_real_escape_string($radius));
What I need to do is get the user_login column from the wp_users table by using the user_id within the statement above.
wp_users TABLE
id | user_login
I’m really not so clear on how to properly JOIN the two statements utilizing a result within the first statement…
Below query should get you the results you need: