Changing existing duplicate entries in mysql?

You need two queries. Assuming you know the position you're inserting, increase the position of each row that has position greater than or equal to the position you're inserting: UPDATE table SET position = position + 1 WHERE position >= newPosition After that, the newPosition can be inserted and no duplicates will exist: INSERT INTO table SET position = newPosition To get the highest value, you can use MAX() SELECT MAX(position) FROM table.

Thanks dude, that solved it! – Mladen May 10 '10 at 23:26 damn, it worked for one row only. If I have more than one row that need to be updated, mysql says: Duplicate entry '2' for key 'position' Any help?

– Mladen May 11 '10 at 9:01 don't mind my last post, I left 'unique' key on position... works fine – Mladen May 11 '10 at 9:10.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions