Invalid query: FUNCTION db_flat_com.POW does not exist SELECT COUNT(DISTINCT(Apartment.id)) as pocet FROM `wapis__apartments` AS `Apartment` LEFT JOIN wapis__owners AS `Owner` ON (Owner.id = Apartment.owner_id) LEFT JOIN wapis__evaluations AS `Evaluation` ON (Apartment.id = Evaluation.apartment_id) LEFT JOIN wapis__list_disposals AS `ListDisposal` ON (ListDisposal.id = Apartment.list_disposal_id) LEFT JOIN wapis__list_city_parts AS `ListCityPart` ON (ListCityPart.id = Apartment.list_city_part_id) LEFT JOIN wapis__apartment_prices AS `ApartmentPrice` ON (ApartmentPrice.apartment_id = Apartment.id AND ApartmentPrice.price) WHERE (3956 * 2 * ASIN(SQRT(POW (SIN((50.083659 - abs( Apartment.latitude)) * pi()/180 / 2),2) + COS(50.083659 * pi()/180 ) * COS( abs(Apartment.latitude) * pi()/180) * POW(SIN((14.356436600000052 - Apartment.longitude) * pi()/180 / 2), 2) ))) < 10 AND Apartment.kos = '0' AND Apartment.status = '1' ORDER BY Apartment.id ASC LIMIT 1