Exception: dead
SELECT uc.*, cm.name AS manufacturer, cr.name AS `range`, cmod.description AS model, cd.description AS derivative, COUNT(DISTINCT uci.id) AS total_images, COUNT(DISTINCT mqe.id) AS enquiries, DATEDIFF( CURDATE( ) , `date_imported` ) AS days_in_stock, IF ( COUNT(uci.id) > 0, 1, 0) AS has_images, uci2.thumblargename AS default_thumblargename, nbs.description AS body_style, ct.description AS transmission, cft.description AS fuel_type, t.value_string AS engine_size, MAX(upc.price_gross) AS max_price FROM used_cars AS uc INNER JOIN cap_manufacturers AS cm ON ( uc.cap_manufacturer_code = cm.code ) INNER JOIN cap_models AS cmod ON ( uc.cap_model_code = cmod.code ) INNER JOIN cap_model_ranges AS cr ON ( uc.cap_range_code = cr.code ) INNER JOIN cap_derivatives AS cd ON ( uc.cap_id = cd.id ) INNER JOIN cap_transmission AS ct ON ( cd.transmission = ct.code ) INNER JOIN cap_fuel_types AS cft ON ( cd.fuel_type = cft.code ) INNER JOIN nvd_body_styles AS nbs ON ( cmod.body_style = nbs.code ) INNER JOIN nvd_technical AS t ON ( t.cap_id = cd.id AND t.tech_code = 146 AND t.effective_to = '0000-00-00' ) LEFT JOIN used_car_price_changes AS upc ON ( uc.id = upc.used_car_id ) LEFT JOIN used_car_images AS uci ON ( uc.id = uci.used_car_id ) LEFT JOIN used_car_images AS uci2 ON ( uc.id = uci2.used_car_id AND uci2.weight = 0 ) LEFT JOIN main_quick_enquiries AS mqe ON ( uc.registration = mqe.registration ) WHERE uc.enabled = 1 AND uc.price_gross > 500 AND uc.override = 0 AND uc.dealership_id = AND uc.managers_special = 1 GROUP BY uc.id You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND uc.managers_special = 1 GROUP BY uc.id' at line 21