MySQL INSERT INTO 语句
我需要一些有关插入语句的帮助。
我有:
my_table_a:
School Latitude Longitude
Old School 38.6... -90.990...
New School 38.6... -90.990...
Other School 38.6... -90.990...
Main School 38.6... -90.990...
my_table_b:
School Latitude Longitude
City School
Old School
Central School
New School
Other School
我需要将 my_table_a 中的纬度和经度插入到 my_table_b 中,其中学校名称之间存在匹配。问题是表 A 没有包含表 B 的所有学校,反之亦然。
我已经尝试过 WHERE 子句,但它不起作用。我需要插入 my_table_a.school = my_table_b.school 。有什么建议吗?
I need some help with an insert statement.
I've got:
my_table_a:
School Latitude Longitude
Old School 38.6... -90.990...
New School 38.6... -90.990...
Other School 38.6... -90.990...
Main School 38.6... -90.990...
my_table_b:
School Latitude Longitude
City School
Old School
Central School
New School
Other School
I need to insert the latitudes and longitudes from my_table_a into my_table_b where there is a match between the school names. The problem is that table A doesn't have all of table B's schools and vice versa.
I've tried a WHERE clause but it's not working. I need to insert where my_table_a.school = my_table_b.school . Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ANSI-92 语法:
使用 ANSI-89 语法:
Using ANSI-92 syntax:
Using ANSI-89 syntax:
您真的要插入还是更新?
怎么样
这将是通用 SQL。我不确定 mysql 是否支持连接更新,这会减少重复性并提高效率。
Do you really want to insert or rather update?
What about
This would be generic SQL. I am not sure if mysql supports an update of a join which would be a bit less repetitive and more efficient.