Re: Problem with sql statement
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 |
+-------------+