如果两个条件正确,即是否有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')
)
最佳答案
您的尝试已接近。尝试这个:select flightnofrom airportwhere flightno IN (select flightno from airport where airport_code='blr') AND flightno IN (select flightno from airport where airport_code='goy')
并以更有效的方式:select flightnofrom airport as awhere 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' )