Geographical proximity query using post_meta

Oh dear, that was extremely obvious – there was a missing closing bracket!
Here is the working query.

SELECT ID, (
     6371 * acos (
     cos ( radians( 35.665833 ) )
     * cos( radians( latitude.meta_value ) )
     * cos( radians( longitude.meta_value ) - radians( 139.731111 ) )
     + sin ( radians(35.665833 ) )                       
     * sin( radians( latitude.meta_value ) )
    )
    ) AS distance
FROM $wpdb->posts
INNER JOIN $wpdb->postmeta latitude
    ON (ID = latitude.post_id AND latitude.meta_key = 'place_latitude')
INNER JOIN $wpdb->postmeta longitude
    ON (ID = longitude.post_id AND longitude.meta_key = 'place_longitude')
HAVING distance < 30
ORDER BY distance
LIMIT 0,6;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)