gpt4 book ai didi

sql - SQL Server 中的 if-then

转载 作者:行者123 更新时间:2023-12-03 01:49:30 25 4
gpt4 key购买 nike

我需要在 SQL Server 中创建一个基本上应该说的命令

If table1.columnx = 1
then update table2 set comumnx = 1

这应该很简单,但我想不出解决方案。

最佳答案

update t2
set columnx = 1
from table1 t1
inner join table2 t2
on t1.id = t2.id
where t1.columnx = 1

关于sql - SQL Server 中的 if-then,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7030237/

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