Invalid query: 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 ) * COS( abs(Apartment.latitude) * pi()/' at line 3 SELECT Apartment.id, Apartment.owner_id, Apartment.list_disposal_id, Apartment.name, Apartment.alias, Apartment.name_en, Apartment.alias_en, Apartment.city, Apartment.list_city_part_id, Apartment.city_district, Apartment.street, Apartment.disposal, Apartment.duration, Apartment.price, Apartment.base_price_persons, Apartment.additional_person_price, Apartment.price_week, Apartment.price_month, Apartment.pet_charge, Apartment.cleanup_charge, Apartment.late_checkup_charge, Apartment.before_checkup_charge, Apartment.area, Apartment.floors, Apartment.beds, Apartment.bathrooms, Apartment.bedrooms, Apartment.parking, Apartment.garden, Apartment.balcony, Apartment.terrace, Apartment.lodge, Apartment.pet_possible, Apartment.recommended, Apartment.description, Apartment.description_en, Apartment.longitude, Apartment.latitude, Apartment.check_availability, Apartment.kos, Apartment.status, Apartment.export_id, Apartment.min_night_stay, 3956 * 3 * ASIN(SQRT(POW(SIN(( - abs( Apartment.latitude)) * pi()/180 / 2),2) + COS( * pi()/180 ) * COS( abs(Apartment.latitude) * pi()/180) * POW(SIN(( - Apartment.longitude) * pi()/180 / 2), 2) )) AS distance FROM `wapis__apartments` AS `Apartment` WHERE Apartment.kos = '0' AND Apartment.status = '1' GROUP BY Apartment.id HAVING distance < 10 ORDER BY distance ASC LIMIT 10