日期:2014-05-17  浏览次数:20444 次

Where 条件
update dbo.RPT_resultA41 set BudgetAvgPerMth=BudgetYtd/9        
                                                        from dbo.RPT_resultA41
                                             where CompanyID=1 and classify=-1

这个  where CompanyID=1 and classify=-1条件属于UPdate 条件是还是 from dbo.RPT_resultA41的条件呢!
update dbo.RPT_resultA41 set BudgetAvgPerMth=(Select BudgetYtd/9 from dbo.RPT_resultA41
                                    where CompanyID=1 and classify=-1)
                                    where CompanyID=1 and classify=-1

这样写是同样结果的,那条件是怎样判断的呢?
------解决方案--------------------
update dbo.RPT_resultA41 set BudgetAvgPerMth=BudgetYtd/9        
                                                        from dbo.RPT_resultA41
                                             where CompanyID=1 and classify=-1
红色部分完全是多余的
------解决方案--------------------
属于from 的条件。其实update的比较完整的格式是:
update tb
set xx=xx
from tb
where
无论单表还是多表都是,只是有些可以省略而已