I have three tables, containing information about three people and the
cars that they own.
One table lists people, one lists cars, and one uses the id's from the
other two to compile a list of which models of car each person owns.
Bob owns a Ford, Paul owns a Toyota, and Dave owns both a Ford and a
Toyota.
Simple.
How do I create a query that will tell me 'which people own a Ford and
do not own a Toyota' - i.e. how do you get a result of just Bob?
table: person
fields: person_id, person_name
data: 1 - Bob, 2 - Paul, 3 - Dave
table: car
fields: car_id, car_name
data: 1 - Ford, 2 - Toyota
table: person_car
fields: person_id, car_id
data: 1 - 1, 2 - 2, 3 - 1, 3 - 2
cars that they own.
One table lists people, one lists cars, and one uses the id's from the
other two to compile a list of which models of car each person owns.
Bob owns a Ford, Paul owns a Toyota, and Dave owns both a Ford and a
Toyota.
Simple.
How do I create a query that will tell me 'which people own a Ford and
do not own a Toyota' - i.e. how do you get a result of just Bob?
table: person
fields: person_id, person_name
data: 1 - Bob, 2 - Paul, 3 - Dave
table: car
fields: car_id, car_name
data: 1 - Ford, 2 - Toyota
table: person_car
fields: person_id, car_id
data: 1 - 1, 2 - 2, 3 - 1, 3 - 2
Comment