级连查询与更新

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

posted @ 2013-11-24 11:59  黑 瞳  阅读(426)  评论(0编辑  收藏  举报