I want to hold ordering of some items in SQL, like field in a table index: 0,1,2,3,4,...
and I have operation moveItem
If I want to move item from index: 1
to index: 3
I can do
delete from table where index = 1;
update table set index = index - 1 where index > 1
update table set index = index + 1 where index >=3
insert into table (index) values (3)