At 11:40 -0700 7/22/03, Cory Lamle wrote:
Contents are Direct Alliance Corporation CONFIDENTIAL
-
How do you type check in mysql.  I have a column of type varchar(20) with
both floats and strings.  Is there a way to check the type?

In this case, the "type" of the column as far as MySQL is concerned is varchar(20). If you want to check the type of individual column values, you'll need to impose your own semantic tests. Depending on how varied your values are, you might be able to use a REGEXP match. For example:

IF(col1 REGEXP '^[0-9]+\\.[0-9]+$','is a float','not a float') AS type

However, that pattern requires digits both before and after the decimal
point and may not be suitable for your purposes.


Example: Select If(is_float(col1), 'is a float', 'not a float') as type From table

Thxs
Cory


--
Paul DuBois, Senior Technical Writer
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

Are you MySQL certified? http://www.mysql.com/certification/


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to