更新操作期间的多个内部联接

时间:2015-02-23 15:56:20

标签: sql ms-access access-vba inner-join

在Access中的更新操作期间是否可以进行双内连接?

以下代码不适用于我:

UPDATE [TableA]

INNER JOIN [TableB] ON [TableB].Field1=  [TableA].Field1,
INNER JOIN [TableC] ON [TableC].Field2 = [TableB].Field2

Set 
[TableA].Field3 = 'Test'

where [TableC].Field4 = 0

2 个答案:

答案 0 :(得分:6)

是的,这是可能的。

SQL SERVER

UPDATE A
Set 
A.Field3 = 'Test'
FROM [TableA] A
INNER JOIN [TableB] B ON B.Field1 = A.Field1
INNER JOIN [TableC] C ON C.Field2 = B.Field2
where C.Field4 = 0

MS ACCESS

UPDATE ([TableA]
INNER JOIN [TableB] ON [TableB].Field1 = [TableA].Field1)
INNER JOIN [TableC] ON [TableC].Field2 = [TableB].Field2
Set [TableA].Field3 = 'Test'
where [TableC].Field4 = 0

答案 1 :(得分:0)

多连接更新操作的一般语法如下:

UPDATE T1
[INNER JOIN | LEFT JOIN] T2 ON T1.C1 = T2.C1
[INNER JOIN | LEFT JOIN] T3 ON T2.C2 = T3.C2
SET T1.C2 = T2.C2
WHERE condition