gpt4 book ai didi

MySQL 更新语句语法错误

转载 作者:行者123 更新时间:2023-11-29 14:09:36 25 4
gpt4 key购买 nike

我有当前的代码,

UPDATE i
SET LeadInventor =
CASE
WHEN gs.FirstInventorName IS NULL THEN 'No'
ELSE 'Yes'
END
FROM patentdb.Inventor i
LEFT JOIN patentdb.generalsource gs
ON i.InventorFirst + ' ' + i.InventorLast = gs.FirstInventorName

我不明白为什么它会抛出以下错误:

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 patentdb.Inventor i     LEFT JOIN patentdb.generalsource gs     ON i.Invent' at line 7

FROM语句是MYSQL所强调的

最佳答案

这是因为 FROM 子句在 MySQL UPDATE 语句中无效:

http://dev.mysql.com/doc/refman/5.6/en/update.html

你可能会有更好的运气:

UPDATE Inventor i, generalsource gs
SET i.LeadInventor = CASE
WHEN gs.FirstInventorName IS NULL THEN 'No'
ELSE 'Yes'
END
WHERE i.InventorFirst + ' ' + i.InventorLast = gs.FirstInventorName

关于MySQL 更新语句语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13731263/

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