update recyclingDamageItem set materialDefinitionId = (select min(m.id) from MaterialDefinition m 
where (case when m.specification is null then m.name else (m.name + '[' + m.specification + ']') END) = recyclingDamageItem.materialName) where materialDefinitionId is null;
