需要基于选定的值

问题描述:

我需要更新基于从另一表中的逻辑是作为查询值的表来更新表如下: 我需要选择列渣油这将具有表示服务器号:需要基于选定的值

Select [resid] from [dbo].[dailyChecksIntegrityErrorState2] 

然后我需要说

if [resid] ='1077' 

然后

update [dbo].[DailyChecks] set prdintegritycheckbox ='0' 

我知道这是一个牛逼的问题,我需要关于如何制定的,如果再/ else语句

+0

样本数据和期望的结果将有助于澄清问题。 –

一些方向这应该工作 Update [dbo].[DailyChecks] set prdintegritycheckbox ='0' where (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'