我有以下表格结构,其中有列 vid,我想输入今天的日期,然后是 00001,例如“2012061000001”,下次表格更新时,vid 应该是“20120610000002”,如果明天表格将得到更新,那么 vid 应该是 2012061100003
+----+------+-------------+---------+------------+-------------+
| id | vid | visitorname | company | contact | whometomeet |
+----+------+-------------+---------+------------+-------------+
| 1 | NULL | rakesh | godrej | 9987654123 | abcdef |
| 2 | NULL | samir | infosys | 9987654123 | abcdef |
+----+------+-------------+---------+------------+-------------+
我们怎样才能做到这一点?
这是我的表结构,我将 id 设置为 auto_increment 我们可以有两个字段 auto_increment
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| vid | varchar(15) | YES | | NULL | |
| visitorname | varchar(255) | YES | | NULL | |
| company | varchar(255) | YES | | NULL | |
| contact | varchar(30) | YES | | NULL | |
| whometomeet | varchar(255) | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
并触发以下查询,我得到如下结果
插入访问者(vid)值(concat(替换(左(current_timestamp,10),'-',''),lpad('1','5','0')));
+----+---------------+-------------+---------+------------+-------------+
| id | vid | visitorname | company | contact | whometomeet |
+----+---------------+-------------+---------+------------+-------------+
| 1 | NULL | rakesh | godrej | 9987654123 | abcdef |
| 2 | NULL | samir | infosys | 9987654123 | abcdef |
| 3 | 2012061000001 | NULL | NULL | NULL | NULL |
+----+---------------+-------------+---------+------------+-------------+
但问题是每次我都会在 vid 中得到那个 1,如果明天我也运行这个查询,我会得到明天的日期,但后面会是 00001,我想要它 00002。