我想把一列数据前全部加0,如何实现啊?
如题!!不要叫我手动添加啊,呵呵
------解决方案--------------------MYSQL?列是什么类型?
update tt set f1=
concat('0',f1)
------解决方案--------------------mysql> create table test_num(id int(6) zerofill);
Query OK, 0 rows affected (0.20 sec)
mysql> insert into test_num values(203);
Query OK, 1 row affected (0.02 sec)
mysql> select * from test_num;
+--------+
| id |
+--------+
| 000203 |
+--------+
1 row in set (0.00 sec)
mysql>
------解决方案--------------------
------解决方案--------------------mysql> create table t1(id int(6));
Query OK, 0 rows affected (0.08 sec)
mysql> insert into t1 values(1003);
Query OK, 1 row affected (0.01 sec)
mysql> select * from t1;
+------+
| id |
+------+
| 1003 |
+------+
1 row in set (0.00 sec)
mysql> alter table t1 modify id int(6) zerofill;
Query OK, 1 row affected (0.04 sec)
Records: 1 Duplicates: 0 Warnings: 0
mysql> select * from t1;
+--------+
| id |
+--------+
| 001003 |
+--------+
1 row in set (0.00 sec)
mysql>