[英]Error on Simple SQL Update Statement
我有一个简单的update语句,但是第二条SET语句却出现错误:期望',',id,伪代码或变量。 我看不到我在做什么错。 请帮忙。
update DLprc
set salesamt = q.salesamt,
set salestx = q.salestx, <<<---- error line
set nsales = q.nsales
from DLprc a
inner join q on a.customer = q.customer
您不需要重复SET
:
update DLprc
set salesamt = q.salesamt,
salestx = q.salestx,
nsales = q.nsales
from DLprc a
inner join q on a.customer = q.customer
我习惯于使用JOIN
进行UPDATE
的以下格式:
update a
set a.salesamt = q.salesamt,
a.salestx = q.salestx,
a.nsales = q.nsales
from DLprc a
inner join q on a.customer = q.customer
这是语法错误。 您必须删除一些关键字:
update DLprc
set salesamt = q.salesamt,
salestx = q.salestx,
nsales = q.nsales
from DLprc a
inner join q on a.customer = q.customer /* You can add more predicates here, too! */
即使有多个谓词(条件),该关键字也始终使用一次。 您可以向任何一个关键字添加更多语句。
为了找到导致语法错误的原因,我研究了其他人如何处理语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.