这是我用来从另一个表更新列的查询:
UPDATE SPICES A
SET A.description = (SELECT CODE
FROM CHILLY B
WHERE SUBSTR(A.description,1,4) = TRIM(B.desc123))
WHERE EXISTS (SELECT 1
FROM CHILLY B
WHERE SUBSTR(A.description,1,4) = TRIM(B.desc123));
但这不是我想要的。要求是使用表CHILLY中的新值(CODE)更新描述的前4个字符。
有什么建议吗?写作查询的新手。
答案 0 :(得分:0)
您应该使用连接运算符来添加其余的描述
UPDATE SPICES A
SET A.description = (SELECT CODE
FROM CHILLY B
WHERE SUBSTR(A.description,1,4) = TRIM(B.desc123)) || SUSBSTR(A.description, 5, 255 )
WHERE EXISTS (SELECT 1
FROM CHILLY B
WHERE SUBSTR(A.description,1,4) = TRIM(B.desc123));