From this site:
Tables:
CREATE TABLE PilotSkills
(pilot_name CHAR(15) NOT NULL,
plane_name CHAR(15) NOT NULL,
PRIMARY KEY (pilot_name, plane_name));
CREATE TABLE Hangar
(plane_name CHAR(15) NOT NULL PRIMARY KEY);
Query:
SELECT DISTINCT pilot_name
FROM PilotSkills AS PS1
WHERE NOT EXISTS
(SELECT *
FROM Hangar
WHERE NOT EXISTS
(SELECT *
FROM PilotSkills AS PS2
WHERE (PS1.pilot_name = PS2.pilot_name)
AND (PS2.plane_name = Hangar.plane_name)));
I understand the problem he used for (set division), including the analogy that describes it as "There are no planes in this hangar that I cannot fly!". What I do not understand is exactly what works here, and how he joins together to do what he says.
You are having trouble indicating the features of my difficulty at the moment ...
Edit: Let me first ask what it is, namely:
SELECT DISTINCT pilot_name
FROM PilotSkills
WHERE NOT EXISTS
(SELECT *
FROM Hangar)
I think that there is no fundamental understanding ...
Edit: not suitable, and it would not be meaningful without a third nested SELECT, right?