自动生成的起始于001的序列号(仅适用于3位数字)-PHP/MYSQL [英] Auto generated sequence number staring from 001 ( ONLY FOR 3 DIGITS) - PHP / MYSQL

查看:1085
本文介绍了自动生成的起始于001的序列号(仅适用于3位数字)-PHP/MYSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP/MYSQL中,我需要自动生成的序列号从001开始仅支持3位数字

I need Auto generated sequence number staring from 001 ONLY FOR 3 DIGITS in PHP / MYSQL

例如:001下一个将是002,下一个将是003 ... 009 .. 010 ..119..120..etc,但生成的编号应按顺序排列,不像001,然后是120或008等,我需要依序号.

ex: 001 next will be 002 and next will be 003 ... 009 .. 010 ..119..120..etc but number generated should be in sequence wise not like 001 then 120 or 008 etc , i need in sequence number.

实际上我有产品跟踪系统.我需要主产品ID +自动序列号的混音器(如果需要,只能更改3位数字),因此我的最终产品ID变为:

actually i have product tracking system . where i need mixer of my main product id + auto sequence number ( only 3 digit can change if wanted ) hence my final product id becomes :

111-001,111-002,111-003,111-004 ....等

111-001 , 111-002 , 111-003 , 111-004 ....etc

注意:该自动序列号将插入到我的mysql数据库中(在更新查询"之后是添加"按钮之后(因此,我的自动序列将通过更新查询"输入数据库))

Note: this auto sequence number will be insert in my mysql database ( after ADD button follows by Update query ( hence my auto sequence will be enter in database with Update query ))

推荐答案

只需将长度3和零填充添加到您的id列中即可.

Just add the length 3 and zerofill to your id column.

ALTER TABLE  `YOUR_TABLE` CHANGE  
`id_column`  `id_column` INT( 3 ) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT

这篇关于自动生成的起始于001的序列号(仅适用于3位数字)-PHP/MYSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆