2016-03-15 49 views
0

我有两个表States和Cities。 在teststates表:有关于不同国家enter image description hereMYSQL代码将两个表中的数据显示为单个数据

代码列有与它

相关联的状态在城市表ID的状态数据: 存在具有相同的ID代码列的区域列测试状态表。 enter image description here

要求: 我想要的代码在MySQL从teststates表列获取ID,并将其更换成区域列在表testcities因为我想只有两列这是城市名称和地区testcities表。请帮帮我!

+0

你想要一个SELECT查询或更新查询。 – Priyanshu

+0

我想要更新查询,首先从teststates表中读取区域,然后更新testcities表中的区域列。 –

+0

你想如何从测试状态获取区域? – Priyanshu

回答

0

select a.name,b.region from teststates a,testcities b where a.country = b.country

这将返回城市名称和地区名称的列从两个表中加入关于国名。

相关问题