我正在使用 Microsoft Access。如果此查询: (SELECT FERMENT.FermentIdFROM FERMENTINNER JOIN [BELGIUM BEER]ONFERMENT.FermentName = [BELGIUM BEER].FermentId ORDER BY [BELGIUM BEER].BeerId) a r...
我正在使用微软 Access。
如果有这个查询:
(SELECT FERMENT.FermentId
FROM FERMENT
INNER JOIN [BELGIUM BEER]
ON
FERMENT.FermentName = [BELGIUM BEER].FermentId ORDER BY [BELGIUM BEER].BeerId) a
返回 FermentId,如何使用该列更新不同的表?
例子:
UPDATE EXAMPLETABLE
SET EXAMPLETABLE.FermentId = a.FermentId
FROM a
(SELECT FERMENT.FermentId
FROM FERMENT
INNER JOIN [BELGIUM BEER]
ON
FERMENT.FermentName = [BELGIUM BEER].FermentId ORDER BY [BELGIUM BEER].BeerId) a
UPDATE T
SET T.FERMENTID = A.FERMENTID
FROM EXAMPLETABLE AS T
INNER JOIN (SELECT FERMENT.FERMENTID,
FERMENT.OTHERID
FROM FERMENT
INNER JOIN [BELGIUM BEER]
ON FERMENT.FERMENTNAME =
[BELGIUM BEER].FERMENTID
ORDER BY [BELGIUM BEER].BEERID) AS A
ON A.OTHERID = T.OTHERID
如果不是这种情况并且子查询返回单个值,请尝试如下操作:
UPDATE EXAMPLETABLE
SET T.FERMENTID = (SELECT FERMENT.FERMENTID
FROM FERMENT
INNER JOIN [BELGIUM BEER]
ON FERMENT.FERMENTNAME =
[BELGIUM BEER].FERMENTID
ORDER BY [BELGIUM BEER].BEERID)