I’m trying to create query to not include the cars where the part_id = ‘1’. This works, but the car continues to show up because the car_id is associated with multiple other part_id’s.
Here’s my query:
SELECT
distinct car.car_id,
part.description
FROM car
JOIN car_parts part on (car.car_id = part.car_id)
WHERE part.part_id <> '1'
My table: car_parts
Car ID | Part ID
1 1
1 3
1 4
2 2
2 5
2 7
3 1
3 4
3 9
4 1
The only car_id that should be returned from the query is car_id = 2.
1 Answer