Maintaining/updating record order in mysql -


I have a table of records in my SQL, as per the user specified, I need to keep an order for them. That's why I've added a 'Position' column.

When I take a specific record, what will be the SQL statement to update all the records? I get something like this:

  updated item SET status = '2' WHERE id = '4'; Update item set status = Status + 1 position where> gt; = '2' and id! = '4';  

But the higher the record goes down, the less will be less than that. what's the trick? Thanks!

For example selling orders with line numbers created by the user, I It's best to organize it in an array in BL or UI, usually they want to adjust several records, and sometimes want to say "forget it" so it can be easiest to "OK" "Do not wait until you press the button (or your equivalent) Write down everything with the current order.

You can also deal with extinction, whatever is the other problem you can handle in the same way.


Comments