In the last episode (Mar 24), Lucas Vendramin said:
> Hi all.
> I have a problem:
> When I compare two strings in mask (x.x.x.x) the comparation is not
> true (for my question :D)... look:
>  select '3.2.0.13' > '3.2.0.2'            -> FALSE
> I want this command return TRUE, but it is returning FALSE. But, if I
> put a space first into the smaller string the camparation will
> returns what I want:
>  select '3.2.0.13' > ' 3.2.0.2'            -> TRUE

Well, that's just because '3' has a higher ascii value than ' '.
 
> How can I check it? There is a way to correct my problem? The string
> is like a IP-ADDRESS where 192.168.0.13 is better than 192.168.0.2,
> but it is not a IPADDRESS column, it is a Version of file (version
> 3.2.0, version 3.2.1, etc...)

You will need to write a stored procedure that splits the strings on
'.'s and compares the numbers separately, or write a C UDF that calls
one of the many C version-comparison functions available (
http://sourcefrog.net/projects/natsort/ ,
http://gcc.gnu.org/svn/gcc/trunk/libiberty/strverscmp.c ).

-- 
        Dan Nelson
        [EMAIL PROTECTED]

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

Reply via email to