Sql 需要根据所选值更新表

Sql 需要根据所选值更新表,sql,tsql,Sql,Tsql,我需要根据另一个表的查询值更新一个表,逻辑如下: 我需要选择列resid,其中的数字表示服务器: Select [resid] from [dbo].[dailyChecksIntegrityErrorState2] 那我得说 if [resid] ='1077' 然后 我知道这是一个新问题,我需要一些关于如何制定if-then/else语句的指导 Update[dbo].[DailyChecks]set prdinintegritycheckbox='0' 其中(从[dbo].[dail

我需要根据另一个表的查询值更新一个表,逻辑如下: 我需要选择列resid,其中的数字表示服务器:

Select [resid] from [dbo].[dailyChecksIntegrityErrorState2]
那我得说

if [resid] ='1077' 
然后

我知道这是一个新问题,我需要一些关于如何制定if-then/else语句的指导
Update[dbo].[DailyChecks]set prdinintegritycheckbox='0'

其中(从[dbo].[dailyChecksIntegrityErrorState2]中选择[resid],其中[resid]='1077')

您似乎想要这样的东西:

update dc
    set prdintegritycheckbox = '0'
    from [dbo].[DailyChecks] dc
    where dc.server in (Select [resid] from [dbo].[dailyChecksIntegrityErrorState2] where resid = '1077')
或:


样本数据和预期结果将有助于澄清问题。
update dc
    set prdintegritycheckbox = '0'
    from [dbo].[DailyChecks] dc
    where dc.server in (Select [resid] from [dbo].[dailyChecksIntegrityErrorState2] where resid = '1077')
update dc
    set prdintegritycheckbox = '0'
    from [dbo].[DailyChecks] dc
    where dc.server in (Select [resid] from [dbo].[dailyChecksIntegrityErrorState2]) and
          dc.server = '1077'