可以在MySQL表中移动行数据吗?

可以在MySQL表中移动行数据吗?,mysql,Mysql,我想将单元格值向右移动,然后更新[row1,col1] 之前: +----------------+------------------+------------------+------------------+ | id(VARCHAR 20) | col1(VARCHAR 10) | col2(VARCHAR 10) | col3(VARCHAR 10) | +----------------+------------------+------------------+----------

我想将单元格值向右移动,然后更新[row1,col1]

之前:

+----------------+------------------+------------------+------------------+
| id(VARCHAR 20) | col1(VARCHAR 10) | col2(VARCHAR 10) | col3(VARCHAR 10) |
+----------------+------------------+------------------+------------------+
| row1           | john             | jane             | jeff             |
+----------------+------------------+------------------+------------------+
| row2           | some             | other            | stuff            |
+----------------+------------------+------------------+------------------+
之后:

+----------------+------------------+------------------+------------------+
| id(VARCHAR 20) | col1(VARCHAR 10) | col2(VARCHAR 10) | col3(VARCHAR 10) |
+----------------+------------------+------------------+------------------+
| row1           | sue*             | john             | jane             |
+----------------+------------------+------------------+------------------+
| row2           | some             | other            | stuff            |
+----------------+------------------+------------------+------------------+
*Sue被插入,前一行的值被向右移动,“jeff”被弹出,可以说,进入了以太;列数是固定的

我问了一个类似的问题,但我想将我的桌子设计旋转90°


提前感谢。

这应该适合您:

update table t
    set col3 = col2,
        col2 = col1,
        col1 = 'sue'
    where id = 'row1';

你为什么要这样做?这强烈表明您没有正确使用关系数据库。