I have a table that basically looks like this:
ID Name
1 test1
2 test2
n testn
I am trying to write a query that first updates 1 row at a time, then if I am feeling greedy, updates all the rows. I tried user-defined variables like this:
SET @x = '1';
SET @name = CONCAT('test', @x);
UPDATE mytable SET Name = @name WHERE ID = @x;
But this query fails. Why is this query failing, and is it possible to improve it to something like a for loop to update every name field in the table? For the latter, is something like this possible?
<for loop>
SET @x = Name;
SET @name = CONCAT('test', @x);
UPDATE mytable SET Name = @name WHERE ID = @x;
<end loop>