Re: padding an id field
| From: | Tim Sawyer | 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:RR> a PKIs there anyway to pad an id field in MySQL? I have a table withRR> afield (id). This field is auto incrementing a 6 digit number ie. 000223. Is there anyway to pad this id so that it is padded withRR> Now Icode along with the auto incrementing part, such as ABC000223.RR> autowouldn't want the ABC pad to change but the 6 digits would stillRR> aincr as required. Is this possible without doing any field editing, exclusively withRR> When you define your auto-incrementing column, can't you specify RR> "ZEROFILL"? I believe it pads to the left with zeroes.MySQL utility? thanks /Merle