UPDATE
(
SELECT
a.COL1
FROM
TABLE1 a,
TABLE2 b,
TABLE3 c
WHERE
a.name = b.name
c.ccol = b.ccol AND
AND b.col1 = 'anyvalue'
AND a.col2 = 'anothervalue'
) u
SET
u.COL1 = 'VALUE'
此查询不起作用,因为TABLE1不包含PK。怎么写这样的查询?
答案 0 :(得分:3)
以下内容应该达到您想要实现的目标:
UPDATE TABLE1
SET COL1 = 'VALUE'
WHERE EXISTS
( SELECT 1
FROM TABLE2 B
INNER JOIN TABLE3 C
ON B.Ccol = C.Ccol
WHERE b.Name = Table1.Name
AND b.Col1 = 'AnyValue'
AND c.Col1 = 'AnotherValue'
)
答案 1 :(得分:0)
我从未在甲骨文工作,但尝试这样的事情。没有PK不应该是一个问题,只要你加入&哪些陈述是正确的。
这是您要求的等同于
的SQLUPDATE u
SET u.COL1 = 'VALUE'
FROM Table1 AS u
INNER JOIN Table2 AS b ON u.name = b.name
INNER JOIN Table3 AS c ON c.ccol = b.ccol
WHERE b.col1 = 'anyvalue' AND u.col2 = 'anothervalue'