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;
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;