Re: padding an id field

From: Date: Thu, 04 Oct 2001 19:22:15 +0000
Subject: Re: padding an id field
References: 1 2 3  Groups: php.db php.general 
Request: Send a blank email to php-db+get-13008@lists.php.net to get a copy of this message
Don't know how to do it in MySQL but how about in php with $var=sprintf("abc%06d", $num); Webdev wrote:
Hello Raquel, Yes, but is it possible to append a code such as 'abc' along with the zerofill to create an id like 'abc000123' for the 123rd id record. /Merle Thursday, October 04, 2001, 1:13:59 PM, you wrote: RR> On Thu, 4 Oct 2001 09:47:16 -0300 RR> WebDev <WebDev@merlepittman.com> wrote:
Is there anyway to pad an id field in MySQL? I have a table with
RR> a PK
field (id). This field is auto incrementing a 6 digit number ie. 000223. Is there anyway to pad this id so that it is padded with
RR> a
code along with the auto incrementing part, such as ABC000223.
RR> Now I
wouldn't want the ABC pad to change but the 6 digits would still
RR> auto
incr as required. Is this possible without doing any field editing, exclusively with
RR> a
MySQL utility? thanks /Merle
RR> When you define your auto-incrementing column, can't you specify RR> "ZEROFILL"? I believe it pads to the left with zeroes.


« previous php.db (#13008) next »