views:

18

answers:

1

i have below table

  it_id     item_id     item_name   
    1   ite_1            shirt
    2   ite_10           pant
    3   ite_11           socks
    4   ite_12           shoes
    5   ite_13            belt

now i need to change item_id with with ite_(value of it_id of that row)

means if it_id=x then item_id should be ite_x and so on...

what will b sql query for that??

UPDATE ###

if i want to change it_id with a prefix means new it_id=ite_x where x is it's(it_id's) previous value(1,2,3,4,5 etc....) and it_id is not an auto increment field

+1  A: 
update table_name SET item_id=CONCAT('ite_', id)

SORRY your column id it_id, so it should be (Not Sure Though)

update table_name SET item_id=CONCAT('ite_', it_id)

I think you can do it with follwing steps
1] Change datatype of it_id to VARCHAR
2] your query is

update table_name SET it_id=CONCAT('ite_', it_id)
Salil
Thank you Salil. is there any method in which we can use previous value of that field with new value. means if i want to add ite_x in each it_id field?( when it_id is not auto increment)
diEcho
sorry i didn't get it? ple explain it in detail or give an example.
Salil
i updated my question, please check
diEcho