update PackingRecord set tousseDefinitionId=(select min(ti.tousseDefinition_id) from TousseInstance ti where ti.packingRecord_id=PackingRecord.id group by ti.packingRecord_id) where tousseDefinitionId is null;