Create ordering in a MySQL table without using a number (because then it's hard to put something in

Posted by user347256 on Stack Overflow See other posts from Stack Overflow or by user347256
Published on 2010-06-14T22:23:09Z Indexed on 2010/06/14 22:32 UTC
Read the original article Hit count: 127

Filed under:
|
|

I have a long list of items (say, a few million items) in a mysql table, let's call it mytable and it has the field mytable.itemid.

The items are given an order, and can be re=ordered by the user by drag and drop. If I add a field called mytable.order and just put numbers in them, it creates problems: what if I want to move an item between 2 other items? Then all the order fields have to be updated? That seems like a nightmare.

Is there a (scalable) way to add order to a table that is different from just giving every item a number, order by that, and do loads of SQL queries everytime the order is changed?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about index