gpt4 book ai didi

mysql - 如何针对这种情况编写嵌套查询?

转载 作者:行者123 更新时间:2023-11-30 00:50:50 26 4
gpt4 key购买 nike

汽车_飞机表

id, aircraft_name, home_base_address,alternate_base_airport 

1 , MIG 20 , 77 , 80

2 , MIG 30 , 80 ,50

cars_airport 表

id ,airport_city , airport_name

1 , mumbai , CST

2 , pune , PIA

我需要airport_name,airport_name作为airport_city="mumbai"的结果。

条件是在搜索中不仅搜索到城市的飞机也会出现还有邻近城市的飞机也应该来。

即孟买的邻居城市是浦那(基于孟买的alternative_base_airport值,即浦那的home_base_address,因此对于孟买搜索孟买和浦那都应该出现)

请帮忙

最佳答案

第二个表看起来与第一个表没有任何关联...但这是您可以执行的操作:

从机场 =“孟买”的表中选择 *联盟select * from table where home_base in (从 table where homebase = "Mumbai"中选择 Alternative_base)

关于mysql - 如何针对这种情况编写嵌套查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20995823/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com