使用 JOIN 3 表更新 Oracle?
Oracle UPDATE with JOIN 3 tables?
UPDATE calculation
LEFT JOIN transportorders ON calculation.ataid = transportorders.nr
LEFT JOIN partner ON partner.taid = transportorders.nr
AND calculation.FZZAEHLER=ATAFRACHTZAHLER.FZZAEHLER
SET calculation.BABRECHNUNGSINFO = '.....'
WHERE calculation.ataid IN
(SELECT transportorders.nr
FROM transportorders
WHERE transportorders.tournr = '212041')
AND partner.kundenid = '2486909';
我正在尝试这段代码,但它给我一个错误,提示找不到 SET 关键字。这意味着连接不是它们应该的那样。我如何在 UPDATE 中进行此选择?常规 SELECT 适用于相同的表格。
尝试 merge
:
MERGE INTO calculation c
USING (SELECT '....' new_value, t.nr
FROM transportoders t LEFT JOIN partner p ON p.taid = t.nr
WHERE t.tournr = '212041'
AND p.kundenid = '2486909') x
ON (c.ataid = x.nr)
WHEN MATCHED
THEN
UPDATE SET c.babrechnungsinfo = x.new_value;
UPDATE calculation
LEFT JOIN transportorders ON calculation.ataid = transportorders.nr
LEFT JOIN partner ON partner.taid = transportorders.nr
AND calculation.FZZAEHLER=ATAFRACHTZAHLER.FZZAEHLER
SET calculation.BABRECHNUNGSINFO = '.....'
WHERE calculation.ataid IN
(SELECT transportorders.nr
FROM transportorders
WHERE transportorders.tournr = '212041')
AND partner.kundenid = '2486909';
我正在尝试这段代码,但它给我一个错误,提示找不到 SET 关键字。这意味着连接不是它们应该的那样。我如何在 UPDATE 中进行此选择?常规 SELECT 适用于相同的表格。
尝试 merge
:
MERGE INTO calculation c
USING (SELECT '....' new_value, t.nr
FROM transportoders t LEFT JOIN partner p ON p.taid = t.nr
WHERE t.tournr = '212041'
AND p.kundenid = '2486909') x
ON (c.ataid = x.nr)
WHEN MATCHED
THEN
UPDATE SET c.babrechnungsinfo = x.new_value;