I have fruits
table, where rows are ordering by index
:
SELECT index, title FROM fruits ORDER BY index;
index | title
-------+--------
1 | Orange
-------+--------
2 | Apple
-------+--------
3 | Banana
-------+--------
4 | Cherry
-------+--------
5 | Strawberry
In client side I have sortable list, where user can drag items and change their order.
I need make query to change this order.
For example, I want to move Apple
row after Cherry
.
The result after query should be:
index | title
-------+--------
1 | Orange
-------+--------
2 | Banana
-------+--------
3 | Cherry
-------+--------
4 | Apple
-------+--------
5 | Strawberry
How I can implement this?