SELECT ogl.id, ogl.ident, ogl.title, ogl.category, ogl.city, ogl.city_rw, ogl.state, ogl.country, ogl.cost, ogl.cost_max, ogl.cost_notice, ogl.cost_currency, ogl.for_free, ogl.status, ogl.display, ogl.forever, ogl.urgent, ogl.create_date, ogl.whole_country, DATEDIFF(CURDATE(), ogl.create_date) AS 'datediff', comp.company_name, comp.company_logo, professions.name AS profession_name, ogl.lat, ogl.lng, ogl.cost_tax, ogl.company_id FROM oglo2023_announcement AS ogl LEFT JOIN oglo2023_announcement_payments AS pay ON ogl.ident=pay.pay_ident AND (pay.pay_type='VIEW' AND pay.pay_expire>='2024-10-10') LEFT JOIN oglo2023_company AS comp ON comp.company_id = ogl.company_id LEFT JOIN oglo2023_professions_list_pl AS professions ON professions.id = ogl.profession LEFT JOIN oglo2023_announcement_additional_localizations AS localizations ON ogl.id = localizations.announcement_id AND (localizations.city LIKE '%ornontowice%' OR LOWER(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(TRIM(localizations.city), ':', ''), ')', ''), '(', ''), ',', ''), '', ''), '', ''), '"', ''), '?', ''), '\'', ''), '&', ''), '!', ''), '.', ''), ' ', '-'), '', ''), '', ''), 'ą', 'a'), 'ż', 'z'), 'ź', 'z'), 'ć', 'c'), 'ń', 'n'), 'ł', 'l'), 'Ł', 'l'), 'ó', 'o'), 'ę', 'e'), 'ś', 's')) LIKE '%ornontowice%') WHERE ogl.status='ACCEPT' AND ogl.display = 'TRUE' AND (((pay.pay_create <= '2024-10-10' OR pay.pay_create <= '2024-10-17' OR pay.pay_create IS NULL) AND pay.pay_expire >= '2024-10-10') OR ogl.forever = 'TRUE') AND ((ogl.city LIKE '%ornontowice%' OR ogl.city_rw LIKE '%ornontowice%') OR (ogl.whole_country = 'TRUE') OR localizations.city <> '') ) AS x Caught exception: 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 ') AS x' at line 1