Erro: 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 '* pi() / 180)) * sin((cid_lat * pi() / 1' at line 12 ------------------------------------ SELECT ATR.latr_id, CID.cid_id, CID.cid_nome, CID.cid_distritode, UF.uf_nom, CID.cid_uf, ( ( ( acos( sin(( * pi() / 180)) * sin((cid_lat * pi() / 180)) + cos(( * pi() /180 )) * cos((cid_lat * pi() / 180)) * cos((( - cid_lon) * pi()/180))) ) * 180/pi() ) * 60 * 1.1515 * 1.609344 ) AS KM, (SELECT COUNT(*) FROM sys_hoteis WHERE ht_cid_id = CID.cid_id AND ht_stt = 'A') as cnt_htl FROM sys_locais_atrib ATR INNER JOIN sys_cidades CID ON ATR.latr_atr_vlr = CID.cid_id INNER JOIN sys_estados UF ON CID.cid_uf = UF.uf_cod WHERE ATR.latr_loc_id = 543 AND ATR.latr_atr_id = 39 ORDER BY CID.cid_uf, CID.cid_nome