This question already has answers here:
From base 10 to base 26 only with letters so that 26 will be aa
(2个答案)
在8个月前关闭。
我大约有300行。我想做的是用MySQL更新所有表。
我要实现的目标:
我有一张桌子,上面有一些行
现在,我要更新此表中的所有行。我想将其更新为
代码应该从
预期的最终结果:
等等。
(2个答案)
在8个月前关闭。
我大约有300行。我想做的是用MySQL更新所有表。
我要实现的目标:
我有一张桌子,上面有一些行
+----------------------------------+
| name | code |
+----------------------------------+
| test | (null) |
| test | (null) |
+----------------------------------+
现在,我要更新此表中的所有行。我想将其更新为
代码应该从
A
开始,然后从B
然后是c
,依此类推,直到到达z
,它应该再次从AA
开始。所以我需要一个为自己设置值的变量。预期的最终结果:
+----------------------------------+
| name | code |
+----------------------------------+
| test | A |
| test | B |
.
.
| test | z |
| test | AA |
| test | AB |
+----------------------------------+
等等。
最佳答案
您可以尝试使用以下SQL:
select
name,
char(row_number() over(order by name) - ceil(row_number() over(order by name)/27.0 - 1)*27+64) as abc_group_num
from
my_table
关于mysql - 如何在MySQL中每行动态更新所有行的动态数据? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/56522328/
10-17 00:01