class.mysql.php : 1054 - Unknown column 'pay.pay_create' in 'order clause' - SELECT * FROM (SELECT ogl.id, ogl.ident, ogl.title, ogl.category, ogl.city, ogl.city_rw, ogl.district, ogl.state, 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.delivery_enabled, ogl.delivery_info, MAX(CASE WHEN pay.pay_type = 'VIEW' THEN pay.pay_expire ELSE NULL END) AS view_till, MAX(CASE WHEN pay.pay_type = 'PROMOTED' THEN pay.pay_expire ELSE NULL END) AS promoted_till, (SELECT GROUP_CONCAT(ph.photo_filename ORDER BY ph.photo_main = 'YES' DESC) FROM ogl24_announcement_photos AS ph WHERE ph.photo_announcement_id = ogl.id) AS photos FROM ogl24_announcement AS ogl LEFT JOIN ogl24_announcement_payments AS pay ON ogl.ident=pay.pay_ident LEFT JOIN ogl24_company AS comp ON comp.company_id = ogl.company_id WHERE ogl.status='ACCEPT' AND ogl.display = 'TRUE' AND (((pay.pay_create <= '2025-01-30' OR pay.pay_create IS NULL) AND pay.pay_expire >= '2024-04-05') OR ogl.forever = 'TRUE') AND ((ogl.city LIKE '%Northampton%' OR ogl.city_rw LIKE '%northampton%') OR (ogl.whole_country = 'TRUE')) AND ogl.category IN (1085,1086,1087,1088,1089,1090,1092,1206,1207,1214,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1521,1522,1524,1525,1526,1527,1528,1529,1530,1800,1045) GROUP BY ogl.id ) AS x ORDER BY (((pay.pay_create <= '2025-01-30' OR pay.pay_create IS NULL) AND pay.pay_expire >= '2025-01-30') OR ogl.forever = 'TRUE') DESC, promoted_till >= '2025-01-30' DESC, ogl.create_date DESC LIMIT 0,20