9
I want to get all pilots who have never performed flights on route 12345, I have tried with NOT IN and so on:
SELECT pl.id
FROM Piloto pl,
Voo v, Rota r
WHERE pl.id = v.id_comandante
AND pl.id = v.id_copiloto
AND v.cod_rota = r.cod_rota
AND r.cod_rota <> 12345
SQL returns nothing. What I’m doing wrong?
These are the tables:
Aviao (matricula, nome, data_aquisicao, TipoAviao.cod_tipo)
Piloto (Tripulante.id, n_aterragens, n_descolagens, n_horas_voo, tipo)
Habilitado (Piloto.id, TipoAviao.cod_tipo, n_licenca, data_licenca)
Rota (cod_rota, Aeroporto.cod_aeroporto_ini, Aeroporto.cod_aeroporto_fim)
Voo (n_voo, data_partida, data_chegada, Rota.cod_rota,
Piloto.id_comandante, Piloto.id_copiloto, Aviao.matricula)
See http://answall.com/questions/62925/not-in-ou-not-exists-qual-use
– Marconi