Two tables are given
PilotGroup Table
Pilot Plane
Jon Smith A1-Fighter
Jon Smith B1-Fighter
Gravell A2-Fighter
Jon Skeet A1-Fighter
Jon Skeet B1-Fighter
Jon Skeet A4-Fighter
Gravell A5-Fighter
SouthOperation Table
Plane
A1-Fighter
B1-Fighter
The task is to print the names of the pilots who are trained for both the A1 Fighter and the B1-Fighter.
I got the result by doing
select distinct pilot from PilotGroup as pg1
where not exists
(
select * from SouthOperation Sop where
not exists
(
select *from PilotGroup as pg2 where ( pg1.pilot = pg2.pilot)
and
(pg2.plane= Sop.plane)
)
)
Are there any alternatives for finding rows in another table?
source
share