我尝试使用另一个表更新一个表中的值,使用IP_ID通过以下sybtax比较2表
UPDATE EDWID02.CUSTOMER_MOBILE t1
SET T1.MOBILE = (
SELECT T2.MOBILE
FROM EDWID02.NEW_MOBILE t2
WHERE T1.IP_ID=T2.IP_ID)
我发现的错误是DB2 Database Error:
ERROR [21000] [IBM][DB2/AIX64] SQL0811N The result of a scalar fullselect,
SELECT INTO statement, or VALUES INTO statement is more than one row.
SQLSTATE=21000
即使我改变了=,它告诉我另一个错误DB2 Database Error:
ERROR [42601] [IBM][DB2/AIX64] SQL0104N An unexpected token "in" was found
following "t1 SET T1.MOBILE". Expected tokens may include: "=".
SQLSTATE=42601
我在DB2中编码。
答案 0 :(得分:0)
你的误解
'UPDATE t1 SET value=onevalue'
onevalue需要是单个值。您可以通过以下方式实现此目的(SELECT值FROM t2 WHERE t1.id = t2.id FETCH FIRST 1 ROW ONLY)