truncating results?

2004-01-16 Thread dan
Hello all,

I'm trying to query a database of speed test results for display on a php
page.  The results are fully-qualified machine names, often very long.  What
I'd like to do is trim it down so only the main domain name is left for
display: for example, '68-65-69-187.vnnyca.adelphia.com' becomes just
'adelphia.com'.  The problem is there is a more or less random amount of
stuff to the left of the goodies I actually want.  So...is there an easy way
to just grab the two right-most bits between the periods?

Thanks bunches!
Dan

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

Re: truncating results?

2004-01-16 Thread Roger Baklund
* dan
 I'm trying to query a database of speed test results for display on a php
 page.  The results are fully-qualified machine names, often very 
 long.  What I'd like to do is trim it down so only the main domain name 
 is left for display: for example, '68-65-69-187.vnnyca.adelphia.com' 
 becomes just 'adelphia.com'.  The problem is there is a more or less 
 random amount of stuff to the left of the goodies I actually want.  
 So...is there an easy way to just grab the two right-most bits between 
 the periods?

See the SUBSTRING_INDEX() function:

mysql select substring_index('68-65-69-187.vnnyca.adelphia.com','.',-2);
++
| substring_index('68-65-69-187.vnnyca.adelphia.com','.',-2) |
++
| adelphia.com   |
++
1 row in set (0.00 sec)

URL: http://www.mysql.com/doc/en/String_functions.html#IDX1210 

-- 
Roger

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