我想将单元格值向右移动,然后更新[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'已被弹出,可以说是进入了以太;列数是固定的。
我问了一个类似的问题here,但我希望将我的桌面设计旋转90°。
提前致谢。
答案 0 :(得分:1)
这应该适合你:
update table t
set col3 = col2,
col2 = col1,
col1 = 'sue'
where id = 'row1';