我的表有两个 FK UserProfile_Id
和 Service_Id
。该表包含我需要更改其值的位字段。
我有两个临时表:
第一个表#temp2:
EmailAddress,
UserProfile_Id
第二个表#temp:
EmailAddress,
Service_Id
这个声明不起作用:
UPDATE MailSubscription SET BitField=1
where UserProfile_id IN ( SELECT UserProfile_Id from #temp2 )
and Service_id IN ( SELECT ServiceId from #temp)
我知道为什么它不起作用,但不知道如何修复它才能正常工作。
我需要为 MailSubscription
更改 bitField
,其中 tuple(UserProfile_Id,Service_Id) 已加入 #temp 和 #temp2,但我可以不要在mssql中这样写。
最佳答案
UPDATE M
SET M.BitField=1
from MailSubscription M
inner join #temp2 t2 on M.UserProfile_id=t2.UserProfile_Id
inner join #temp t on M.Service_id=t.ServiceId
and t.EmailAddress=t2.EmailAddress
关于sql - 选择语句中的元组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17922077/