RE: [PHP-DB] Re: IS_NUMERIC ?. .

From: Date: Tue, 29 Nov 2005 20:06:16 +0000
Subject: RE: [PHP-DB] Re: IS_NUMERIC ?. .
Groups: php.db 
Request: Send a blank email to php-db+get-40738@lists.php.net to get a copy of this message
> -----Original Message----- > From: El Bekko [mailto:elbekko@gmail.com] > > http://php.belnet.be/manual/en/function.is-numeric.php > > Apparently there is :) > > > Dwight Altman wrote: > > Hello List, > > Is there an IS_NUMERIC(aCandidateString) function in MySQL that I can run in > > a query, similar to the various PHP "is_*" functions? I can't seem to find > > it in the docs (other than a C API IS_NUM macro). > > > > I have a field in a database with serial numbers like: > > ...1234 > > ...1235 > > ...1236-A > > ...1237B > > and I want to get the last 4 characters of the numeric substring like so: [snip] Last I checked, MySQL doesn't support PHP functions natively :) His question was whether there's an equivalent function to that in MySQL, and I agree with a previous answer, you can use a REGEXP ( http://dev.mysql.com/doc/refman/4.1/en/regexp.html ) if there is nothing else available. (example - randomly scrounged together) REGEXP '^.*[:digit:]{4}.[^:digit:]*$' ( {1,4} if you want the last group of up to 4 digits) cheers, - Martin Norland, Sys Admin / Database / Web Developer, International Outreach x3257 The opinion(s) contained within this email do not necessarily represent those of St. Jude Children's Research Hospital.

« previous php.db (#40738) next »