更新选择的结果
我有一个表 caxnode,其中包含字段 node_alias、node_mode、node_id 等。
在某些情况下,node_alias 被标记为“常规”以及不同 node_id 的“逻辑”。我想将相同的 node_alias 标记为“常规”和“逻辑”的条目更改为逻辑。即,如果同一个条目在表中被标记为“逻辑”并且是一个 LDOM 分区,则将“常规”更改为“逻辑”。
这是我的工作查询,用于返回我有兴趣更改的结果。
select Node_ID, Node_type, Num_of_proc, Node_Alias, Host_ID, Node_mode, Partition_Type
from CAXNODE nd
where (Node_mode = 'VIRTUAL' or Node_mode = 'REGULAR')
and Node_Alias in
(select nd2.Node_Alias
from CAXNODE nd2
where nd2.Node_mode = 'LOGICAL' and Partition_Type = 'LDOM'
) ;
现在我想更改值以将 Node_mode 设置为“逻辑”; Partition_Type 为“LDOM”,Host_ID 为 (nd2.Host_ID); Num_of_proc 到 (nd2.Num_of_proc);
我怎样才能在一个更新声明中做到这一点?
I have a table caxnode which has fields node_alias, node_mode, node_id, etc..
In some cases, the node_alias is marked as "regular" as well as 'logical' for different node_id's. I want to change the entries for which the same node_alias is marked 'regular' as well as 'logical' to logical. i.e. change the "regular" to "logical" if the same entry is marked 'logical' in the table and is an LDOM partition ..
This is my working query to return the results that I am interested in changing..
select Node_ID, Node_type, Num_of_proc, Node_Alias, Host_ID, Node_mode, Partition_Type
from CAXNODE nd
where (Node_mode = 'VIRTUAL' or Node_mode = 'REGULAR')
and Node_Alias in
(select nd2.Node_Alias
from CAXNODE nd2
where nd2.Node_mode = 'LOGICAL' and Partition_Type = 'LDOM'
) ;
Now I want to change the values to set Node_mode to 'LOGICAL'; Partition_Type to 'LDOM', Host_ID to (nd2.Host_ID); Num_of_proc to (nd2.Num_of_proc);
How can I do this in one update statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的。删除 SELECT,并替换为 UPDATE [target],然后添加更改的 SET 列表。
Easy. Remove the SELECT, and replace with UPDATE [target], then add the SET list of changes.