SELECT ogl.id, ogl.ident, ogl.title, ogl.category, ogl.city, ogl.city_rw, ogl.country, ogl.cost, ogl.cost_notice, ogl.cost_currency, ogl.for_free, ogl.status, ogl.display, ogl.forever, ogl.urgent, ogl.create_date, ogl.whole_country, ogl.company_id, pay.pay_expire AS view_till, (SELECT pay_expire FROM oglo2_announcement_payments WHERE pay_ident = ogl.ident AND pay_type = 'PROMOTED' AND pay_expire>='2025-10-27' LIMIT 1) AS promoted_till, (SELECT GROUP_CONCAT(ph.photo_filename ORDER BY ph.photo_main = 'YES' DESC) FROM oglo2_announcement_photos AS ph WHERE ph.photo_announcement_id = ogl.id) AS photos FROM oglo2_announcement AS ogl LEFT JOIN oglo2_announcement_payments AS pay ON ogl.ident=pay.pay_ident AND pay.pay_type='VIEW' INNER JOIN oglo2_announcement_payments AS pay_promoted ON ogl.ident=pay_promoted.pay_ident AND pay_promoted.pay_type='PROMOTED' AND pay_promoted.pay_expire >= NOW() LEFT JOIN oglo2_company AS comp ON (comp.company_id = ogl.company_id AND comp.company_uid > 0) WHERE (ogl.status='ACCEPT' OR ogl.status='NOT_CONFIRMED') AND ogl.display = 'TRUE' AND (((pay.pay_create <= '2024-11-01' OR pay.pay_create <= '2025-10-27' OR pay.pay_create IS NULL) AND pay.pay_expire >= '2024-11-01') OR ogl.forever = 'TRUE') AND ogl.category IN (1326) HAVING main_till >= '2025-10-27' ORDER BY RAND() LIMIT 4 Caught exception: Query failed: Unknown column 'main_till' in 'having clause' array(4) { [0]=> array(5) { ["file"]=> string(72) "/home/posrednik/domains/posrednik.pl/public_html/classes/mysql.class.php" ["line"]=> int(243) ["function"]=> string(7) "doQuery" ["class"]=> string(5) "MySQL" ["type"]=> string(2) "->" } [1]=> array(5) { ["file"]=> string(92) "/home/posrednik/domains/posrednik.pl/public_html/modules/announcement/announcement.class.php" ["line"]=> int(2576) ["function"]=> string(8) "sqlQuery" ["class"]=> string(5) "MySQL" ["type"]=> string(2) "->" } [2]=> array(5) { ["file"]=> string(86) "/home/posrednik/domains/posrednik.pl/public_html/modules/announcement/announcement.php" ["line"]=> int(200) ["function"]=> string(30) "userSearchAnnouncementStandard" ["class"]=> string(12) "Announcement" ["type"]=> string(2) "->" } [3]=> array(4) { ["file"]=> string(60) "/home/posrednik/domains/posrednik.pl/public_html/content.php" ["line"]=> int(403) ["args"]=> array(1) { [0]=> string(86) "/home/posrednik/domains/posrednik.pl/public_html/modules/announcement/announcement.php" } ["function"]=> string(7) "include" } }