[英]update from result of a subquery
Hi i want upadte a data from the result of a subquery嗨,我想从子查询的结果中更新数据
UPDATE A
SET A.a = (select a from A inner join B on B.b=A.c and
B.cf='RGNVQE63H48J869P' and B.b=2345 and
CAST(A.a as decimal)>1);
I want that Aa=result of a subquery.我想要 Aa=子查询的结果。
Use a correlated subquery.使用相关子查询。 Your code has an issue because the table being updated is repeated in the subquery:
您的代码有问题,因为正在更新的表在子查询中重复:
UPDATE A
SET A.a = (SELECT b.a
FROM B
WHERE B.b = A.c AND
B.cf = 'RGNVQE63H48J869P' AND
B.b = 2345 and
CAST(A.a as decimal) > 1
);
Notes:笔记:
0
will be assigned.0
。 This answers the question you have asked here.这回答了您在这里提出的问题。 If this doesn't do what you really need, ask a new question with sample data, desired results, an appropriate database tag, and a clear explanation of what you want to do.
如果这不能满足您的真正需要,请使用示例数据、所需结果、适当的数据库标签以及对您想要做什么的清晰解释提出一个新问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.