我有一个名为country_id的mysql数据库列,例如:
country_id
----------
1
2
59
435
2714
我现在想要完成的是将前导零添加到每个 ID,因此结果将是:
country_id
----------
0001
0002
0059
0435
2714
每个 ID 最多应包含 4 位数字。就是这样。
我可以在 PHPmyAdmin 中使用任何 SQL 语句以上述方式更新此country_id 列吗?
此致!
Declare ZEROFILL
在专栏上:
mysql> create table foobar (nr integer(4) ZEROFILL);
Query OK, 0 rows affected (0.31 sec)
mysql> INSERT INTO foobar VALUES (1),(12),(123),(1234),(12345);
Query OK, 5 rows affected (0.05 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM foobar;
| 0001
| 0012
| 0123
| 1234
| 12345
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)