我会尽力简化情况...... 我与一个现场服务技术人员团队合作。我们之间分享了很多工具和设备,因为有些人不想花钱给我们。我正在使用MS Access开发一种方法来跟踪谁拥有大约2000多个项目池中的工具或特定设备。我已经把这个过程弄清楚了最后一步。它是这样的:
我已经按照每个教程,完成并解决了我能理解的问题。但每次我运行查询时,Access都会询问我参数值"参数值"我想要更新的每个字段。请注意,我发现的所有内容都显示了如何更新表中一个字段的示例。我想尝试每行更新5个字段。当我让Access为此构建SQL时,它看起来像:
UPDATE Table1 INNER JOIN Table2
ON Table1.[Asset ID] = Table2.[Asset ID]
SET Table1.Department = Table2.[Department], Table1.[Cal Status] = Table2.
[Cal Status], Table1.[Return Date] = Table2.[Return Date], Table1.Comments =
Table2.[Comments], Table1.[Cal Due] = Table2.[Cal Due], Table1.Active =
Table2.[Active];
字段没有拼写错误,我已经检查过并仔细检查过。
我已经看到一些关于Access如何解决UPDATE问题的评论。但我自学了我所做的一切,在我明白这一点之前我无法转向其他事情。我刚刚在本周初开始使用Access和SQL,所以请耐心等待我。
修改
UPDATE Assets
SET Assets.Department = AssetsSharePoint.[Department],
Assets.[Cal Status] = AssetsSharePoint.[Cal Status],
Assets.[Return Date] = AssetsSharePoint.[Return Date],
Assets.Comments = AssetsSharePoint.[Comments],
Assets.[Cal Due] = AssetsSharePoint.[Cal Due],
Assets.Active = AssetsSharePoint.[Active]
FROM Assets
INNER JOIN AssetsSharePoint ON Assets.[Asset ID] = AssetsSharePoint.[Asset
ID];
这给了我一个"语法错误。缺少操作员"然后重点介绍FROM
编辑2
如果我将其减少为1个字段,请忽略FROM
,并将WHERE
包括在内。我不想为此做5个单独的查询。但我想我将不得不......
答案 0 :(得分:0)
您的语法已关闭,应为UPDATE ... SET ... FROM
:
UPDATE t1
INNER JOIN Table2 t2
ON t1.[Asset ID] = t2.[Asset ID]
SET
t1.Department = t2.[Department],
t1.[Cal Status] = t2.[Cal Status],
t1.[Return Date] = t2.[Return Date],
t1.Comments = t2.[Comments],
t1.[Cal Due] = t2.[Cal Due],
t1.Active = t2.[Active]
答案 1 :(得分:0)
试试这个:
UPDATE Assets, AssetsSharePoint
SET Assets.Department = AssetsSharePoint.[Department],
Assets.[Cal Status] = AssetsSharePoint.[Cal Status],
Assets.[Return Date] = AssetsSharePoint.[Return Date],
Assets.Comments = AssetsSharePoint.[Comments],
Assets.[Cal Due] = AssetsSharePoint.[Cal Due],
Assets.Active = AssetsSharePoint.[Active]
WHERE Assets.[Asset ID] = AssetsSharePoint.[Asset ID];
Neater声明:
UPDATE Assets INNER JOIN AssetsSharePoint ON Assets.[Asset ID] = AssetsSharePoint.[Asset ID]
SET Assets.Department = AssetsSharePoint.[Department],
Assets.[Cal Status] = AssetsSharePoint.[Cal Status],
Assets.[Return Date] = AssetsSharePoint.[Return Date],
Assets.Comments = AssetsSharePoint.[Comments],
Assets.[Cal Due] = AssetsSharePoint.[Cal Due],
Assets.Active = AssetsSharePoint.[Active]