I'm running the following MySQL query to find cars that don't have manuals (and have black wheels, etc.)
SELECT `cars`.* FROM `cars`
INNER JOIN wheels ON cars.id = wheels.car_id
LEFT OUTER JOIN manuals ON cars.id = manuals.car_id
WHERE (cars.created_at > '2010-09-09'
AND wheels.color = 'Black'
AND wheels.created_at < '2011-01-05'
AND manuals.car_id IS NULL)
The results of the query look correct, but it returns the car with id 27 twice. How do I change the query so that all results are unique (no duplicates)?
You could try SELECT DISTINCT
instead of SELECT