我正确使用更新吗?

时间:2013-10-22 18:38:28

标签: sql sql-update

我想说的是: “如果RC.Expiration大于或等于今天的日期且RC.DemoLicense等于0,则将DemoTracking.Purchased设置为1”我只需要查看DT.Purchased为0的条目。

update WebCatalog.Published.DemoTracking
set Purchased = 1
from WebCatalog.Published.RCompany RC
inner join WebCatalog.Published.DemoTracking DT
    on RC.Link = DT.RCompanyLink and DT.Purchased = 0
where RC.Expiration >= GETDATE() and RC.DemoLicense = 0

1 个答案:

答案 0 :(得分:0)

试试这个

update WebCatalog.Published.DemoTracking
set Purchased = 1
where Purchased = 0 and RCompanyLink in (select Link as RCompanyLink from WebCatalog.Published.RCompany where RC.Expiration >= GETDATE() and RC.DemoLicense = 0)