我有以下 SQL 代码:
SELECT
`table1`.`field1`
, `view1`.`newfield1`
FROM
`table1`
INNER JOIN `GCOTDA2`.`view1`
ON (`table1`.`id1` = `view1`.`id1`) AND (`table1`.`id2` = `view1`.`id2`);
查询工作正常,但现在我想将 view1.newfield1 复制到 table1.field1。因此,我写了以下声明:
UPDATE `table1`
SET
`table1`.`field1` = `view1`.`newfield1`
FROM
`table1`
INNER JOIN `view1`
ON (`table1`.`id1` = `view1`.`id1`) AND (`table1`.`id2` = `view1`.`id2`);
但是,更新不起作用,我收到以下错误消息:
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM
`table1`
INNER JOIN `view1`
' at line 4
我在这个网站上查看了谷歌和其他问题,例如:如何从 SQL Server 中的 SELECT 更新?和错误代码:mysql中的 1064 没有运气。(MySQL Server 5.5.27) 我需要有人来照亮我,谢谢!