I have a 10k rows db, each one rappresenting a contract with a name on it, there are different contract with the same name and I would like to add a column with the same number for the same name. To select all the names I implemented this:
SELECT cliente FROM tbl_c WHERE id IN
(SELECT MAX(id) FROM tbl_c GROUP BY name)
Now I would like to loop in something like this
SET @num:=10000
FOR EACH Element IN *Selection Above*
UPDATE tbl_c
SET num_column=@num WHERE name=Element
@num:=@num+1
Is it possible to do something like this with mysql?