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_city72.lng) * COS(lat / 57.3), 2)) AS distance ' at line 2 SELECT DISTINCT lang_city72.*, lang_country.name as cname, SQRT( POW(69.1 * (lang_city72.lat - ), 2) + POW(69.1 * ( - lang_city72.lng) * COS(lat / 57.3), 2)) AS distance FROM lang_country, lang_city72 Where lang_city72.id IN (82203,82214,82186,82236,82197,82299,82346,82213,82294,82202) and lang_country.country_id = lang_city72.country_id and lang_country.lang_id = 72 and lang_country.country_id = '9' and lang_city72.id <> 82256 group by lang_city72.short_name ORDER BY distance limit 0, 10