早上好的社区。 p>
我一直在使用MSSQL,并且没有使用MSSQL这个问题,所以它似乎是Oracle处理sql的一种方式。基本上,我需要根据where条件更新表DANIEL_ALERT中的两列。但是,我得到了“ORA-00904:”ALERT_CATEORIES“。”ALERT“:无效的标识符。我确信这只是oracle做与MSSQL不同的事情的方式。
任何想法都将不胜感激。提前谢谢你:)
UPDATE DANIEL_ALERT
SET DANIEL_ALERT.ALERT_CATEGORY = ALERT_CATEGORIES.INDICATION,
DANIEL_ALERT.ALERT_THEME = ALERT_CATEGORIES.THEME
WHERE DANIEL_ALERT.ALERT_NAME = ALERT_CATEGORIES.ALERT;
commit;
答案 0 :(得分:1)
不知道你的表格结构和内容是什么样的,你可以采用这种方法,同时使用,或作为已发布的完美MERGE
答案的替代方案:
UPDATE DANIEL_ALERT DA
SET (DA.ALERT_CATEGORY, DA.ALERT_THEME) = (
SELECT AC.INDICATION, AC.THEME
FROM ALERT_CATEGORIES AC
WHERE AC.ALERT = DA.ALERT_NAME
)
WHERE EXISTS (
SELECT NULL
FROM ALERT_CATEGORIES AC
WHERE AC.ALERT = DA.ALERT_NAME
);
答案 1 :(得分:1)
UPDATE DANIEL_ALERT DA
SET (DA.ALERT_CATEGORY, DA.ALERT_THEME) = (
SELECT AC.INDICATION, AC.THEME
FROM ALERT_CATEGORIES AC
WHERE AC.ALERT = DA.ALERT_NAME
)
WHERE EXISTS (
SELECT NULL
FROM ALERT_CATEGORIES AC
WHERE AC.ALERT = DA.ALERT_NAME
);
答案 2 :(得分:0)
在Oracle中,通常使用MERGE
语句更新包含来自另一个表的值的表。类似的东西:
merge into DANIEL_ALERT d
using ALERT_CATEGORIES c
on (d.ALERT_NAME = c.ALERT)
when matched then update
set ALERT_CATEGORY = c.INDICATION,
ALERT_THEME = c.THEME
;
答案 3 :(得分:-1)
尝试:
更新DANIEL_ALERT SET t1.ALERT_CATEGORY = t2.INDICATION, t1.ALERT_THEME = t2.THEME 来自DANIEL_ALERT t1 INNER JOIN ALERT_CATEGORIES t2 ON t2.ALERT = t1.ALERT_NAME