I have a database that all have a unique ID. They are in ascending order, and I would like to do..
update text SET name = 'hello french man' where id=1;
And change the name of every row to this data I have. So I can keep incrementing
id = id + 1;
But the problem occurs here, I’ve deleted some rows in the past, so there are missing IDs. For instance, there’s row 1,2,3,5. Row 4 is missing because I had deleted it, so how can I update every row without skipping a name because updating row 4 won’t do anything?
It is crucial that I have a 1-1 mapping with all of them and do not skip any names since order matters.
Thanks, any help is much appreciated!
You can use this solution:
See the SQLFiddle Demo