级连查询与更新

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

转载于:https://www.cnblogs.com/ushou/p/3439877.html

猜你喜欢

转载自blog.csdn.net/weixin_34072159/article/details/93765212
今日推荐