mysql 主键自动增长 主键是p001,p002的增长 用什么办法可以实现表主键p001p002p003p004的增长,写一个函数,还是过程来实现那?怎么编? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 表主键定为 1,2,3 N显示的时候select p+right(id+1000,3) == 思想重于技巧 == 你确定都是'p' + 001, 002, ... 999的这种模式吗?不知道下边是不是你想要的?mysql> create table t3(fid int(3) zerofill not null auto_increment primary key,col2 varchar(32));Query OK, 0 rows affected (0.08 sec)mysql> insert into t3 values(null, 'iihero');Query OK, 1 row affected (0.03 sec)mysql> insert into t3 values(null, 'iihero1');Query OK, 1 row affected (0.03 sec)mysql> insert into t3 values(null, 'iihero3');Query OK, 1 row affected (0.08 sec)mysql> select concat('p', fid), col2 from t3;+------------------+---------+| concat('p', fid) | col2 |+------------------+---------+| p001 | iihero || p002 | iihero1 || p003 | iihero3 |+------------------+---------+3 rows in set (0.00 sec) create table t3(fid int(3) zerofill not null auto_increment primary key, col2 varchar(32);中的zerofill是什么意思?为什么就只是001三位那,那他自动增加到999以后还会增加吗? int(4)可以到9999int(10)可以到9999999999 如何制作一个MySQL5.0的存储过程 高密度执行的sql(返回数据5万)优化? mysql官方网站下载的问题 求mysql存储过程详解 程序执行mysql语句和实际操作mysql结果不一样? 关于SQL问题, 高手请教, 多种方法更好 PostgreSQL 之间怎么实现同步? 关于搜索的问题 commit ,unlock table慢 一张表中数据如何交叉组成集合的语句? 用户-朋友列表数据库设计与性能 请教一个MYSQL查询的问题,感谢关注的朋友:)
定为 1,2,3 N
显示的时候
select p+right(id+1000,3)
mysql> create table t3(fid int(3) zerofill not null auto_increment primary key,
col2 varchar(32));
Query OK, 0 rows affected (0.08 sec)mysql> insert into t3 values(null, 'iihero');
Query OK, 1 row affected (0.03 sec)mysql> insert into t3 values(null, 'iihero1');
Query OK, 1 row affected (0.03 sec)mysql> insert into t3 values(null, 'iihero3');
Query OK, 1 row affected (0.08 sec)mysql> select concat('p', fid), col2 from t3;
+------------------+---------+
| concat('p', fid) | col2 |
+------------------+---------+
| p001 | iihero |
| p002 | iihero1 |
| p003 | iihero3 |
+------------------+---------+
3 rows in set (0.00 sec)
col2 varchar(32);
中的zerofill是什么意思?
为什么就只是001三位那,那他自动增加到999以后还会增加吗?
int(10)可以到9999999999