我想更新列PPVGLAccountID = 5
的值。目前显示81。
但是问题是同一表中没有下面的列。
如何使用查询UPDATE和SET?
谢谢
我的代码是:
UPDATE dbo.POInvoicingDetails
SET PPVGLAccountID = '5'
FROM dbo.POInvoicingDetails
INNER JOIN dbo.POInvoicing PPVGLAccountID ON dbo.POInvoicingDetails.POInvoicingID
WHERE dbo.POInvoicing.InvoiceNo = '421009'
但是在需要条件的上下文中指定非布尔类型的表达式时,我得到一个错误。
答案 0 :(得分:1)
我想这就是你想要的:
UPDATE id
SET PPVGLAccountID = '5'
FROM dbo.POInvoicingDetails id INNER JOIN
dbo.POInvoicing i
ON id.POInvoicingID = i.POInvoicingID
WHERE i.InvoiceNo = '421009';
您的ON
子句缺少JOIN
条件。
答案 1 :(得分:0)
在您的查询中,INNER JOIN
中的语法不正确,因此必须将其略微更改为如下所示的正确语法,希望您使用的条件正确
UPDATE dbo.POInvoicingDetails
SET PPVGLAccountID ='5'
FROM dbo.POInvoicingDetails
--Condition were missing in the below line compare below line you will get the point
INNER JOIN dbo.POInvoicing ON dbo.POInvoicing.POInvoicingID = dbo.POInvoicingDetails.POInvoicingID
WHERE dbo.POInvoicing.InvoiceNo = '421009'
'421009'--Should not in the quote if it's not `STRING or CHARACTER` type
注意:您可以使用表alias
来简化代码编写和缩短代码