I have 4 tables:
//car id_car | name | id_wheel | id_motor | id_transmission --------+-------+----------+----------+----------------- 1 | car_1 | 1 | 1 | 1 2 | car_2 | 2 | 2 | 2 //motor id_motor | name ----------+---------- 1 | motor_01 2 | motor_02 3 | motor_03 //wheel id_wheel | name ----------+---------- 1 | wheel_01 2 | wheel_02 3 | wheel_03 //transmission id_transmission | name -----------------+---------- 1 | trans_01 2 | trans_02 3 | trans_03 In the car table, the fields id_wheel , id_moto , id_transmission refer to corresponding fields in other tables. In addition to these three, there are no links anywhere else.
My task is to write a query script that returns all names of unused parts.
From the beginning, I wrote this:
select m.name from motor as m left outer join car as c on m.id_motor = c.id_motor where c.name is null; But when I wanted to add unused parts from the rest of the tables to the same query, I realized that at an impasse since the main table I can have only one ...
Help please write such a request.