Wednesday 15 April 2015

sorting - Update sort order in MySQL along with insertion -


I have mysql table pages in sort_order , and I sort Let me drag them to the list, and that order will save the database, 1 will be at the top, and the ASC will be according to the larger number in order Now when I enter a new entry, because sort_order is empty, It comes at the top, I want it to come down.

I do not remember at all, but I think there was another appropriate way to update sort_order with the entry in MySQL, but now I can not do that.

I am trying to do this:

  // in the MYSQL INSERT pages tab // and then  

I I want to run this query:

  Set UPDATE pages sort_order = max (sort_order) +1 where id = {id} <  

Try something like:

  updated pages SET sort_order = ((Select select_value (select subscribe) Selected_values ​​from pages in sub-select_value) + 1)  

No comments:

Post a Comment