gpt4 book ai didi

MYSql代码将两个表中的数据显示到单个表中

转载 作者:行者123 更新时间:2023-11-29 21:15:13 24 4
gpt4 key购买 nike

我有两个表“州”和“城市”。在teststates表中:有关于不同国家的州的数据enter image description here

代码列具有与其关联的州的 ID

在城市表中: 有一个区域列与 teststates 表中的代码列具有相同的 id。 enter image description here

要求:我希望 mysql 中的代码从 teststates 表列中获取 id 并将其替换为 testcities 表中的区域列,因为我只需要两列,即 testcities 表中的城市名称和区域。请帮助我!

最佳答案

从测试状态 a、测试城市 b 中选择 a.name、b.region,其中 a.country = b.country

这将返回连接两个表中的国家/地区名称的城市名称和地区名称列。

关于MYSql代码将两个表中的数据显示到单个表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36004491/

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