我尝试根据2个内部联接更新表中的字段,但它不适用于我。我一直收到语法错误。
UPDATE t1
SET t1.value = t3.value
FROM Table1 as t1
INNER JOIN Table2 as t2 ON t1.name = t2.name
INNER JOIN Table3 as t3 ON t2.address = t3.address;
表格结构:
name value
---- -----
bob ***
tom ***
name address
---- -------
bob 100 main st
tom 200 fake dr
address value
----------- -------
100 main st 200
200 fake dr 400
因此值200和400是我尝试更新空白的原因。
答案 0 :(得分:0)
UPDATE t1
SET value = t3.value
...
答案 1 :(得分:0)
您可以使用以下
UPDATE table1 t1
SET t1.VALUE =
(SELECT t3.VALUE
FROM table2 t2, table3 t3
WHERE t1.name = t2.name AND t2.address = t3.address)