List:General Discussion« Previous MessageNext Message »
From:Claudio Nanni Date:October 15 2009 9:56am
Subject:Re: is_string or is_numeric
View as plain text  
Only in the case you want to know the datatype and not the actual type of
information in a char field!

If you issue:

show fields from MyTable like 'FName';

you get:
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| FName | varchar(255) | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+

although is not a function if you place the result into an array on the
application side you can pull the value of the Type attribute.


Hope this helps anyway!


Claudio


2009/10/15 Glyn Astill <glynastill@stripped>

> > From: sangprabv <sangprabv@stripped>
> > Subject: is_string or is_numeric
> > To: mysql@stripped
> > Date: Thursday, 15 October, 2009, 10:34 AM
> > Hi,
> > I found no built in function in mysql to check whether a
> > record is
> > numeric or string. Is there any trick to do so? Many
> > thanks.
>
> You could use some regex to do it...
>
> In fact, a google brings up this (
> http://forums.mysql.com/read.php?60,1907,241284#msg-241284)
>
> CREATE FUNCTION ISNUMERIC(myVal VARCHAR(1024))
> RETURNS TINYINT(1) DETERMINISTIC
> RETURN myVal REGEXP '^(-|\\+)?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$';
>
>
> Glyn
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=1
>
>


-- 
Claudio

Thread
is_string or is_numericsangprabv15 Oct
  • Re: is_string or is_numericGlyn Astill15 Oct
    • Re: is_string or is_numericClaudio Nanni15 Oct
  • Re: is_string or is_numericwalter harms15 Oct