级连查询与更新

select DATEADD(day,v.LearningDay,sc.OrderTime) AS OrderPayDate, sc.LearninTime,v.VideoTitle,sc.OrderTime,v.LearningDay from
ShoppingCart sc
left join video v
on sc.MatterId=v.Id
where sc.OrderTime is not null


update sc
set sc.LearninTime = r.OrderPayDate
from ShoppingCart sc,
(select sc.Id, DATEADD(day,v.LearningDay,sc.OrderTime) AS OrderPayDate, sc.LearninTime,v.VideoTitle,sc.OrderTime,v.LearningDay from
ShoppingCart sc
left join video v
on sc.MatterId=v.Id
where sc.OrderTime is not null
) as r
where sc.Id=r.Id

你可能感兴趣的:(查询)