大概思路1.先获取要删除记录的vip,和每个vip共删除的总分
select vip,sum(total) from xf where xf_id in(1,2,3,4) group by vip;
保存为数组
vip为key
total为value$arr = array(
'1' => 110,
'2' => 80,
'3' => 50
);2.删除对应xf_id的记录
delete from xf where xf_id in(1,2,3,4);3.修改vip表
foreach($arr as $vip=>$total){
update vip set jifen=jifen-$total where vip=$vip
}
select vip,sum(total) from xf where xf_id in(1,2,3,4) group by vip;
保存为数组
vip为key
total为value$arr = array(
'1' => 110,
'2' => 80,
'3' => 50
);2.删除对应xf_id的记录
delete from xf where xf_id in(1,2,3,4);3.修改vip表
foreach($arr as $vip=>$total){
update vip set jifen=jifen-$total where vip=$vip
}
for each row
BEGIN
UPDATE users SET users.sum = users.sum -
(SELECT sum(jifen.jifen) from jifen WHERE jid = old.jid) where users.userid = old.userid;
END
'1' => 110,
'2' => 80,
'3' => 50
);这里用字段名怎么写?
用php 数组保存.
$arr = array(
'1' => 110,
'2' => 80,
'3' => 50,
'4' => 30,
等等
);
select vip,sum(total) from xf where xf_id in(1,2,3,4) group by vip;
然后把select的保存在数组就可以了。