update idcardinstance set lostDate=(
(select max(operationtime) from MaterialErrorDamageDetail md 
where md.idCardInstanceId= (select min(iii.id) from idcardinstance iii 
where iii.idcarddefinitionid=idcardinstance.idcarddefinitionid and iii.id>idcardinstance.id ))
)
where status='已丢失'
and lostDate is null;