I just did the oposite :o)
set @a='0123FOO';
set @b=substring(0+concat('9',@a),-length(0+concat('9',@a))+1);
select @b,replace(@a,@b,'');
have to concat a positive number !!!
Selon [EMAIL PROTECTED]:
> Hi all,
> The trick i can see if the string start with '0' is to make it starting with
> a
Hi all,
The trick i can see if the string start with '0' is to make it starting with a
positive number.
FOr example if my string is '0123FOO' :
set @a='0123FOO';
set @b=substring(0+concat('0',@a),-length(0+concat('0',@a))+1);
select @b,replace(@a,@b,'');
Mathias
Selon gerald_clark <[EMAIL P
clark" <[EMAIL PROTECTED]>
To: "Eamon Daly" <[EMAIL PROTECTED]>
Cc: "dixie" <[EMAIL PROTECTED]>; "MySQL"
Sent: Tuesday, April 26, 2005 8:10 AM
Subject: Re: extract numeric value from a string.
Eamon Daly wrote:
Easy enough. Get the numeric
Eamon Daly wrote:
Easy enough. Get the numeric part via CONVERT, then get the
rest of the string from the length of the numeric part, plus
one:
SELECT
tag,
@num := CONVERT(tag, SIGNED) AS num_part,
SUBSTRING(tag, LENGTH(@num) + 1) AS rest_of_string from tags;
++--++
Easy enough. Get the numeric part via CONVERT, then get the
rest of the string from the length of the numeric part, plus
one:
SELECT
tag,
@num := CONVERT(tag, SIGNED) AS num_part,
SUBSTRING(tag, LENGTH(@num) + 1) AS rest_of_string from tags;
++--++
| tag| num_par