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 pilot names who is trained on both A1-Fighter and B1-Fighter.
I got the result by executing
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)
)
)
Is there any alternatives to search the rows against other table?