update的where中如何做sum并判断

来源:互联网 发布:淘宝优惠卷海报 编辑:程序博客网 时间:2024/05/22 11:51
update table_name 
                                   set status = 2 
where 
             #{cnum} = 
    (
select v.cSum from
                                                (
                        select sum(columnA) cSum
                        from table_name 
                        where status = 1 and user_id = 1 and invalid_time > now()
                               ) as v
              )
             and status = 1 and user_id = 1;
原创粉丝点击