我的尝试:
UPDATE [DATA OUTPUT TABLE]
(
SELECT [DATA OUTPUT TABLE].[Journal Voucher ID], [DATA OUTPUT TABLE].[dBranch] AS Branch, [DATA OUTPUT TABLE].[dBranch] & " Shared Appropriation" AS [Shared Appropriation]
FROM [DATA OUTPUT TABLE]
WHERE [DATA OUTPUT TABLE].[Journal Voucher ID] In
(
SELECT [DATA OUTPUT TABLE].[Journal Voucher ID]
FROM [DATA OUTPUT TABLE]
GROUP BY [DATA OUTPUT TABLE].[Journal Voucher ID]
HAVING
(((First([DATA OUTPUT TABLE].dBranch)="Navy")
AND
(Last([DATA OUTPUT TABLE].dBranch)="USMC"))
OR
((First([DATA OUTPUT TABLE].dBranch)="USMC")
AND
(Last([DATA OUTPUT TABLE].dBranch)="Navy")))
)
;) AS SATable
SET [DATA OUTPUT TABLE].[Shared Appropriation] = SATable.[Shared Appropriation]
Where [DATA OUTPUT TABLE].[Journal Voucher ID] = SATable.[Journal Voucher ID], [DATA OUTPUT TABLE].[dBranch] = SATable.[Branch];
我的目标是使用[dBranch]字段和"的串联更新[DATA OUTPUT TABLE]中的[Shared Aropriation]列。共享拨款"从我的查询(有效):
SELECT [DATA OUTPUT TABLE].*
FROM [DATA OUTPUT TABLE]
WHERE ((([DATA OUTPUT TABLE].[Journal Voucher ID]) In (SELECT [DATA OUTPUT TABLE].[Journal Voucher ID]
FROM [DATA OUTPUT TABLE]
GROUP BY [DATA OUTPUT TABLE].[Journal Voucher ID]
HAVING (((First([DATA OUTPUT TABLE].dBranch))="Navy") AND ((Last([DATA OUTPUT TABLE].dBranch))="USMC")) OR (((First([DATA OUTPUT TABLE].dBranch))="USMC") AND ((Last([DATA OUTPUT TABLE].dBranch))="Navy"));)));
我的想法是为工作查询创建一个别名SATable,并将其抛入更新查询。
答案 0 :(得分:0)
您的查询可以重写为:
UPDATE [DATA OUTPUT TABLE]
SET [DATA OUTPUT TABLE].[Shared Appropriation] = [dBranch] & " Shared Appropriation"
Where [DATA OUTPUT TABLE].[Journal Voucher ID] IN
(
SELECT [DATA OUTPUT TABLE].[Journal Voucher ID]
FROM [DATA OUTPUT TABLE]
GROUP BY [DATA OUTPUT TABLE].[Journal Voucher ID]
HAVING
(((First([DATA OUTPUT TABLE].dBranch)="Navy")
AND
(Last([DATA OUTPUT TABLE].dBranch)="USMC"))
OR
((First([DATA OUTPUT TABLE].dBranch)="USMC")
AND
(Last([DATA OUTPUT TABLE].dBranch)="Navy")))
)