You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '), 2) + POW(69.1 * ( - lang_city3.lng) * COS(lat / 57.3), 2)) AS distance ' at line 2 SELECT DISTINCT lang_city3.*, lang_country.name as cname, SQRT( POW(69.1 * (lang_city3.lat - ), 2) + POW(69.1 * ( - lang_city3.lng) * COS(lat / 57.3), 2)) AS distance FROM lang_country, lang_city3 Where lang_city3.id IN (90338,66022,66053,66005,66037,66018,90340,66013,66033,66015) and lang_country.country_id = lang_city3.country_id and lang_country.lang_id = 3 and lang_country.country_id = '62' and lang_city3.id <> 66010 group by lang_city3.short_name ORDER BY distance limit 0, 10