MySQL Forums
Forum List  »  Stored Procedures

Re: question
Posted by: Peter Brawley
Date: October 08, 2012 12:16PM

Unfortunatelt MySQL's regex implementation doesn't support returning matching substrings. Given a varchar column v, the simplest way to get a leading numeric value from a string is to write ...

select v+0;

but whether that's enough for you depends on your rules for the column, eg ...

drop table if exists t;
create table t(v varchar(16));
insert into t values('1abc'),('abc2'),('abc3def4');
select v+0 from t;
+------+
| v+0  |
+------+
|    1 |
|    0 |
|    0 |
+------+

Options: ReplyQuote


Subject
Views
Written By
Posted
1609
October 07, 2012 10:43PM
Re: question
967
October 08, 2012 12:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.