Using MySQL 4.0.20, I need to extract just the numeric portion of a string in a field and move it to another field in the same table, but I'd only like to do this if the value actually starts with a number. So, what I'm looking to accomplish is:
UPDATE table SET field2 = VOODOO( field1 )


The fields are currently defined as:
field2  INT( 10 )
field1  CHAR( 19 )

The table is relatively small, with about 55,000 records in it.

Here is the type of data I find in field1 and next to it, what I'd like to wind up with in field2:
1234 -> 1234
12345 -> 12345
123456 -> 123456
1234567 ->1234567
1234NN -> 1234
12345NN ->12345
123456N -> 123456
1234567 -> 1234567
WWW -> WWW
NC -> NC


There is other data, but most of it follows that rule. If I can do this with MySQL, I would prefer it. If it's something I should farm out to PHP or Perl, I can do that, but I was trying to think of how to accomplish this just within MySQL and don't really know how to approach it.

Any pointers would be appreciated. Thanks.

Wes


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



Reply via email to