在做ecshop的时候遇到这个问题,虽然看似简单,可写这个sql花不少时间啊,做个保存,没事可以自己看看
update `gjmm20160612`.`ecs_user_bonus` AS a set a.user_id=363534 where a.bonus_id = any
(select b.bonus_id from
(
select bonus_id from `gjmm20160612`.`ecs_user_bonus` as b where exists ( select bonus_id from `gjmm20160612`.`ecs_user_bonus` c where b.bonus_id = c.bonus_id and c.bonus_type_id= 241 and c.user_id=0
)
limit 0,1
)
b
)
原文地址:http://xihan.blog.51cto.com/11171003/1955106