我需要获取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')
)
最佳答案
你的尝试已经很接近了。尝试这个:
选择航类号
从机场
其中航类号 IN(从机场选择航类号,其中 airport_code='blr')
AND 航类号 IN(从 airport_code='goy' 的机场选择航类号)
并以更有效的方式:
选择航类号
从机场作为
哪里存在(
选择1
从机场出发
其中 a.flightno = b.flightno
和 airport_code='blr'
)
并且存在(
选择1
从机场出发
其中 a.flightno = c.flightno
和 airport_code='goy'
)
关于mysql - 实现满足两个条件的Mysql子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22902144/