MySQL Forums
Forum List  »  Newbie

Re: Problem with sql statement
Posted by: Chris Stubben
Date: March 24, 2005 05:32PM

Hi again,

I think I responded to a related post of yours earlier. Just use nested substring_indexes instead.


Chris


select ip from tmp order by ip;
+-------------+
| ip |
+-------------+
| 10.10.21.10 |
| 10.10.5.10 |
| 10.10.60.10 |
| 10.3.60.10 |
+-------------+


SELECT ip
FROM tmp
order by
substring_index(substring_index(ip, '.', 1), '.', -1)+0,
substring_index(substring_index(ip, '.', 2), '.', -1)+0,
substring_index(substring_index(ip, '.', 3), '.', -1)+0,
substring_index(substring_index(ip, '.', 4), '.', -1)+0;

+-------------+
| ip |
+-------------+
| 10.3.60.10 |
| 10.10.5.10 |
| 10.10.21.10 |
| 10.10.60.10 |
+-------------+

Options: ReplyQuote


Subject
Written By
Posted
Re: Problem with sql statement
March 24, 2005 05:32PM


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.