Re: Inserting a seperator in long numbers

From: Date: Wed, 08 Sep 2004 19:04:02 +0000
Subject: Re: Inserting a seperator in long numbers
References: 1 2 3 4 5 6  Groups: php.db 
Request: Send a blank email to php-db+get-36116@lists.php.net to get a copy of this message
From: "Shiloh Madsen" <shiloh_madsen@nsc-support.com>
I have several tables with long numbers whose digits are always in some multiple of 8 eg 00000000 or 0000000000000000 etc...up to 160 digits long. The numbers all have a number of digits that is some multiple of 8. What I need to do is write an sql update query that will insert a - or some other seperator character every 8 digits in cases where the number of digits is higher than 8 i.e. 00000000-00000000, and so on for bigger numbers. What query would i use to do this?
Since this is a PHP list... $formatted_number = preg_replace('/([0-9]{8})/','\1-',$number); although that leaves a - character on the end to strip off. I'm sure there are other ways. If you want a query to do this, then other than being off topic, it'd help if you told us what database you are using. Not everyone uses MySQL... ---John Holmes...

« previous php.db (#36116) next »