UPDATE sale_origin_line set state='cancel' from sale_origin p,sale_origin_line q where p.id=q.order_id and p.company_id='3' and p.date<'2017-08-01';