How to shift column data using UPDATE in a MySQL table? -


I want to use a fixed-size table like this:

  + --- --- + ---------- + ----------- + | ID | Col1 | Col2 | + ------ + ---------- + ----------- + | 1 | One | X | + ------ + ---------- + ----------- + | 2 | B Y + ------ + ---------- + ----------- + | 3 | C. Jade. + ------ + ---------- + ----------- +  

What a way to move columns For example, when I update [3, col1] then data up? The table should look like this ...

  + ------ + ---------- + ----------- + | ID | Col1 | Col2 | + ------ + ---------- + ----------- + | 1 | B X | + ------ + ---------- + ----------- + | 2 | C. Y + ------ + ---------- + ----------- + | 3 | D * | Jade. + ------ + ---------- + ----------- +  

* New in line 3, call 1 Value] and column data has been moved; thank you in advanced.

You can do this update / join :

  update table t left table tnext on t.id = tnext.id - 1 set t.col1 = (case 'tnext.col1 end when tnext.id is zero) ;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -