insert into detalle select id_detalle, case nov_id when 3 then 100 when x then y ..... [else] end as nov_id_arreglado , aforo_id, ref_arte from temporal_detalle;