如果两个条件正确,我需要获得flightno
,即如果有flightno with airportcode ='something' AND if there is a flightno with airportcode='another'
。
如果这两个航班都不相同,则返回航班号。
我试过了
select flightno
from airport
where flightno = (
select flightno from airport
where airport_code='blr')
AND
(select flightno from airport where airport_code='goy')
)
答案 0 :(得分:0)
你的尝试很接近。试试这个:
select flightno
from airport
where flightno IN (select flightno from airport where airport_code='blr')
AND flightno IN (select flightno from airport where airport_code='goy')
并以更有效的方式:
select flightno
from airport as a
where exists (
select 1
from airport as b
where a.flightno = b.flightno
and airport_code='blr'
)
and exists (
select 1
from airport as c
where a.flightno = c.flightno
and airport_code='goy'
)