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



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

i want utilize static-sized table this:

+------+----------+-----------+ | id | col1 | col2 | +------+----------+-----------+ | 1 | | x | +------+----------+-----------+ | 2 | b | y | +------+----------+-----------+ | 3 | c | z | +------+----------+-----------+

is there way shift column info upwards when update [3, col1] example? table should this...

+------+----------+-----------+ | id | col1 | col2 | +------+----------+-----------+ | 1 | b | x | +------+----------+-----------+ | 2 | c | y | +------+----------+-----------+ | 3 | d* | z | +------+----------+-----------+

*new value in [row3, col1] , column info has been shifted up; in advance.

you can update/join:

update table t left bring together table tnext on t.id = tnext.id - 1 set t.col1 = (case when tnext.id null 'd' else tnext.col1 end);

mysql

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -