gpt4 book ai didi

MySQL INSERT INTO 语句

转载 作者:行者123 更新时间:2023-11-29 05:44:45 24 4
gpt4 key购买 nike

我需要一些关于插入语句的帮助。

我有:

我的表_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...

我的表_b:

School        Latitude     Longitude
City School
Old School
Central School
New School
Other School

我需要将 my_table_a 中的纬度和经度插入到 my_table_b 中,其中学校名称之间存在匹配项。问题是表 A 没有表 B 的所有学校,反之亦然。

我试过 WHERE 子句,但它不起作用。我需要插入 where my_table_a.school = my_table_b.school 。有什么建议吗?

最佳答案

使用 ANSI-92 语法:

UPDATE TABLE_B
JOIN TABLE_A ON TABLE_A.school = TABLE_B.school
SET latitude = TABLE_A.latitude,
longitude = TABLE_A.longitude

使用 ANSI-89 语法:

UPDATE TABLE_B, TABLE_A
SET latitude = TABLE_A.latitude,
longitude = TABLE_A.longitude
WHERE TABLE_A.school = TABLE_B.school

关于MySQL INSERT INTO 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3375347/

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