gpt4 book ai didi

sql - 使用选择查询更新表

转载 作者:行者123 更新时间:2023-11-29 14:08:05 26 4
gpt4 key购买 nike

如果仅满足 where 子句中的语句,我将尝试从 updatedTable 表更新 desiredValue,否则不应设置值。下面的说法正确的是?

 update updatedTable si  
set desiredValue = select desiredValue
from otherTable sl
where sl.att1 = si.att1 and sl.att2 = si.att2;

最佳答案

尝试如下:

UPDATE updatedTable
set updatedTable.desiredValue = otherTable.desiredValue
FROM otherTable
WHERE updatedTable.att1 = otherTable.att1 and updatedTable.att2 = otherTable.att2

关于sql - 使用选择查询更新表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58742978/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com