update ta_help_initiate_record a left join ta_help_activity b on a.help_activity_id = b.help_activity_id set a.status = '2' where (NOW() > b.end_date or b.activity_status = '2') and a.`status` = '1' and a.status != '0'