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

求update语句!请各位XDJM不吝赐教!
我有一张表perfor,有如下字段
ID   ,status,campaign
现在要根据上一个月status求下一个月的status,如
ID         status     campaign
0001     1               200701
那么
ID         status     campaign
0001     2               200702
Update语句如何写?谢谢了!




------解决方案--------------------
update perfor a set a.status = (
select 
case b.id 
when 1 then 2 
when 0 then 4 
end
where a.id =b.id 
and b的月份=a的月份-1)