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 'AND cars.model_id = 1418 ORDER BY RAND() LIMIT 5' at line 13 - SELECT DISTINCT(cars.car_id), cars.*, manufacturers.name AS manufacturer, models.name AS model FROM cars, manufacturers, models LEFT JOIN cars_to_feature ON cars.car_id = cars_to_feature.car_id LEFT JOIN feature ON cars_to_feature.feature_id = feature.feature_id WHERE cars.active = 'Y' AND cars.deleted = 'Y' AND cars.manufacturer_id = manufacturers.manufacturer_id AND cars.model_id = models.model_id AND cars.manufacturer_id = AND cars.model_id = 1418 ORDER BY RAND() LIMIT 5