日期:2014-05-18 浏览次数:20574 次
update user set user.coin=user.coin+ footballrec.getcoin,user.jifen=user.jifen + case when not EXISTS(select id from A where Auserid=user.id) then case when footballrec.getcoin - footballrec.betcoin >=1000 and footballrec.getcoin - footballrec.betcoin <10000 then 1 when footballrec.getcoin - footballrec.betcoin >=10000 and footballrec.getcoin - footballrec.betcoin <50000 then 2 when footballrec.getcoin - footballrec.betcoin >=50000 then 3 else 0 end else 0 end ,user.jifenall=user.jifenall+ case when not EXISTS(select id from A where Auserid=user.id) then case when footballrec.getcoin - footballrec.betcoin >=1000 and footballrec.getcoin - footballrec.betcoin <10000 then 1 when footballrec.getcoin - footballrec.betcoin >=10000 and footballrec.getcoin - footballrec.betcoin <50000 then 2 when footballrec.getcoin - footballrec.betcoin >=50000 then 3 else 0 end else 0 end ,user.jyan=user.jyan+( case when footballrec.betcoin >=50000 and footballrec.betcoin <100000 then 1 when footballrec.betcoin >=100000 and footballrec.betcoin <200000 then 2 when footballrec.betcoin >=200000 and footballrec.betcoin <500000 then 5 when footballrec.betcoin >=500000 and footballrec.betcoin <1000000 then 10 when footballrec.betcoin >=1000000 then 15 else 0 end ) from user inner join footballrec on user.id=footballrec.userid where footballrec.betnum= + @bnum
update [user] set coin = m.coin + n.getcoin, jifen = m.jifen + ( case when n.getcoin - n.betcoin >= 1000 and n.getcoin - n.betcoin < 10000 then 1 when n.getcoin - n.betcoin >= 10000 and n.getcoin - n.betcoin < 50000 then 2 when n.getcoin - n.betcoin >= 50000 then 3 else 0 end ), jifenall = m.jifenall + ( case when n.getcoin - n.betcoin >= 1000 and n.getcoin - n.betcoin < 10000 then 1 when n.getcoin - n.betcoin >= 10000 and n.getcoin - n.betcoin < 50000 then 2 when n.getcoin - n.betcoin >= 50000 then 3 else 0 end ), jyan = m.jyan + ( case when n.betcoin >= 50000 and n.betcoin < 100000 then 1 when n.betcoin >= 100000 and n.betcoin < 200000 then 2 when n.betcoin >= 200000 and n.betcoin < 500000 then 5 when n.betcoin >= 500000 and n.betcoin < 1000000 then 10 when n.betcoin >= 1000000 then 15 else 0 end ) from [user] m inner join footballrec n on m.id = n.userid and n.betnum = @bnum inner join a on a.Auserid = m.id
------解决方案--------------------