小弟我想把一列数据前全部加0,怎么实现啊

我想把一列数据前全部加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>




探讨

update chinapostalcode set 区号 = concat(‘0’,区号)

我是这样写的,可是不行,提示说Data too long for column ” at row 1,单引号里乱码了



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> 

小弟我想把一列数据前全部加0,怎么实现啊

相关文章:

你感兴趣的文章:

标签云: