-1

I am on now a big project and need to update database from MySQL, i need to update a field with some (variable value + that field value). I can do with a static value.

Here is what i have:

UPDATE table SET field_name = concat("static_value", field_name)

What i need to achieve the static_value value should be dynamic, it will start from 1 and ends with the number of rows.

How can i do this? help me!!!

Murad Hasan
  • 9,565
  • 2
  • 21
  • 42

1 Answers1

-1

I got my result. By setting a variable i can achieve what i need. Thanks to @AniMenon.

SET @a:=0;
UPDATE table SET `field_name` = concat(@a:=@a+1, `field_name`);
Murad Hasan
  • 9,565
  • 2
  • 21
  • 42