如果这些条件满足,我正在更新名为“sample”的表中的两列,其值为5;
1)如果TABLE A.MEM_NBR = TABLE B.MEM_NBR AND TABLE B.M_ID = XXXX, AND TABLE B.CLCL = 1
并最终使用类似TABLE A.ID = SAMPLE.ID
的连接条件
2)如果这些条件不够,那么我们不需要更新表格。
但是我收到了一个错误;
SQL Error: ORA-00913: too many values
00913. 00000 - "too many values".
需要一些关于上述更新脚本的帮助,以及我出错的地方。
我使用的脚本如下;
UPDATE SAMPLE
SET SAMPLE.PCB = 5, SAMPLE.PCBP_Q = 5
WHERE (
SELECT *
FROM MEMBER_A A,S_NEW B
WHERE A.MEM_NBR = B.MEM_NBR
AND B.M_ID = 1111
AND B.CLCL = 1
AND B.ID = C.ID);
答案 0 :(得分:1)
问题是您的子查询可以返回多个值。要解决此问题,您可以使用EXISTS
关键字。 (我还将连接转换为ANSI语法。)
UPDATE SAMPLE C
SET C.PCB = 5, C.PCBP_Q = 5
WHERE EXISTS (
SELECT 1
FROM
MEMBER_A A
JOIN S_NEW B
ON A.MEM_NBR = B.MEM_NBR
AND B.M_ID = 1111
AND B.CLCL = 1
WHERE
A.ID = C.ID);
答案 1 :(得分:0)
你的情况可能是错的。它导致匹配许多值而没有映射
试试这个
UPDATE SAMPLE
SET SAMPLE.PCB = 5, SAMPLE.PCBP_Q = 5
WHERE ColumnNmae IN (
SELECT ColumnName
FROM MEMBER_A A,S_NEW B
WHERE A.MEM_NBR = B.MEM_NBR
AND B.M_ID = 1111
AND B.CLCL = 1
AND B.ID = C.ID);
或者使用像这样的相关子查询:
UPDATE SAMPLE
SET SAMPLE.PCB = 5, SAMPLE.PCBP_Q = 5
WHERE EXISTS (
SELECT 1
FROM MEMBER_A A,S_NEW B
WHERE A.MEM_NBR = B.MEM_NBR
AND B.M_ID = 1111
AND B.CLCL = 1
AND B.ID = C.ID
AND A.ColumnNmae = SAMPLE.ColumnNmaes);