为什么此更新查询添加记录?

时间:2015-07-14 18:51:13

标签: sql ms-access ms-access-2010

我有两个数据库,n和p。以下是我尝试使用的更新查询。我希望它添加从n到p的日期和项目编号。出于某种原因,在我运行查询后,我最终得到了更多的记录,然后我就开始了。这是怎么回事?

UPDATE DatesAndProjectNumbers

AS n 

LEFT JOIN Projects 

AS p 

ON (n.[Customer Number] = p.[Customer Number]) 

AND (n.[Measure Received] = p.[Measure Received]) 

SET p.PO = [n].[PO], p.[PGI/Invoice] = [n].[PGI/Invoice], p.Cancelled = [n].[Cancelled];

1 个答案:

答案 0 :(得分:1)

http://blog.sqlauthority.com/2013/04/30/sql-server-update-from-select-statement-using-join-in-update-statement-multiple-tables-in-update-statement/

UPDATE DatesAndProjectNumbers

AS n 

INNER JOIN Projects 

AS p 

ON (n.[Customer Number] = p.[Customer Number]) 

AND (n.[Measure Received] = p.[Measure Received]) 

SET p.PO = [n].[PO], p.[PGI/Invoice] = [n].[PGI/Invoice], p.Cancelled = [n].[Cancelled];