Assuming that your text data is in the column `userinput` and you want the 
integer values to be in the column `numericvalue`, this statement will 
populate the `numericvalue` column all at once:

UPDATE `odd_data_table` SET `numericvalue` = `userinput` + 0;

You are better off checking for type-correctness before you enter data 
into the database than you are trying to correct it after the input. 
However, I have had to do just this kind of conversion on many occasions 
(old data, bad batch inputs, text file bulk loads, etc.)  so I know 
techniques like this still have their place.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Test USER <[EMAIL PROTECTED]> wrote on 12/09/2005 03:30:17 PM:

> in an application i have written there is the need to do a search from 
mysql 
> using numbers that are stored in a varchar column. it is not 
> possible to store 
> only the results with numbers in a seperate column.
> so i was looking at CAST(), is this a big performance loss? is theresome 
way 
> of benchmarking different queries easy?
> 
> -------------------------------------------------
> FREE E-MAIL IN 1 MINUTE!
>  - [EMAIL PROTECTED] - http://www.pc.nu
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 

Reply via email to