update tb
inner join (
select 'TMA-1-2014-0001' as key, 'TMA-2014-0-0001' as value
union all
select 'TMA-2-2014-0001', 'TMA-2014-1-0001'
) as tmp on tmp.key = tb.key
set tb.key=tmp.value
update tb
inner join (
select 'TMA-1-2014' as key, 'TMA-2014-0' as value
union all
select 'TMA-2-2014', 'TMA-2014-1'
) as tmp on tb.key like concat( tmp.key, '%')
set tb.key=concat( tmp.value, substring(tb.key, 10, 5))
$sql="update table_name
inner join (
select 'TMA-1-2014' as key, 'TMA-2014-0' as value
union all
select 'TMA-2-2014', 'TMA-2014-1'
) as tmp on table_name.key like concat( tmp.key, '%')
set table_name.key=concat( tmp.value, substring(table_name.key, 10, 5))";
$result=mysql_query($sql);
update tb
inner join (
select 'TMA-1-2014' as key, 'TMA-2014-0' as value
union all
select 'TMA-2-2014', 'TMA-2014-1'
) as tmp on tb.key like concat( tmp.key, '%')
set tb.key=concat( tmp.value, substring(tb.key, 10, 5))
Code (SQL)
update table_name as tb
inner join (
select 'TMA-1-2014' as k, 'TMA-2014-0' as value
union all
select 'TMA-2-2014', 'TMA-2014-1'
) as tmp
on tb.nt_name like concat( tmp.k, '%')
set tb.nt_name = concat( tmp.value, substring( tb.nt_name, 11, 5))