请问本声明中的错误在哪里,我想更新表1的field1,表2的field2连接字段3上的两个表
UPDATE
(SELECT IP_ANAGRAFICACOMPLESSO.id_complesso, COORDOK6.AZIENDA , IP_ANAGRAFICACOMPLESSO.COORD_GB_E, COORDOK6.WGSE
FROM ip_anagraficacomplesso
INNER JOIN COORDOK6 ON IP_ANAGRAFICACOMPLESSO.ID_COMPLESSO = COORDOK6.AZIENDA )
SET IP_ANAGRAFICACOMPLESSO.COORD_GB_E = COORDOK6.WGSE
非常感谢
答案 0 :(得分:0)
不确定您使用的是哪种SQL,但至少在TSQL中,您需要重新排列它,以便SELECT
位于SET
之后
UPDATE IP
SET IP.COORD_GB_E = C.WGSE
FROM IP_ANAGRAFLICACOMPLESSO IP
INNER JOIN COORDOK6 C ON IP.ID_COMPLESSO = C.AZIENDA
答案 1 :(得分:0)
要在ORACLE中执行此类UPDATE
,您的查询应如下所示。永远记住要创建适当的连接,否则你最终可能会更新错误的记录。
update DAILY D
set
(
D.DEPARTMENT_CODE,
D.COSTCENTRE_CODE,
D.USER_ID
)
=
(select distinct DEPT.DEPT_CODE,
DEPT.CENTRE_CODE,
PRT.EMP_ID
from EMP PRT
inner join DEPT DEPT
on DEPT.DEPARTMENT_ID = PRT.DEPARTMENT_ID
where PRT.LOGIN_ID = D.LOGIN_ID
);
答案 2 :(得分:0)
根据此URL,语法为:
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/update_statement.htm
(ORACLE提供的语法示例):
UPDATE employee_temp SET (first_name, last_name) =
(SELECT first_name, last_name FROM employees
WHERE employee_id = employee_temp.employee_id);
这将是这样的:您只能选择一列 从SELECT子查询 - 确保子查询是有效的INNER JOIN 关于列和表名:
UPDATE COORD_GB_E
SET IP_ANAGRAFICACOMPLESSO =
(SELECT COORDOK6.WGSE
FROM ip_anagraficacomplesso INNER JOIN COORDOK6
ON IP_ANAGRAFICACOMPLESSO.ID_COMPLESSO = COORDOK6.AZIENDA );
此文档说明是否有一列正在更新以省略更新列周围的括号。