Try the INET_ATON function
SELECT ip FROM sn_192_168_0
ORDER BY INET_ATON(ip);
Give it a try !!!
CAVEAT: Better not store the values of INET_ATON. There are some past quirks with this feature: you have invalid numbers between points and call them to triggers.
Now these errors are cleared.
Short IP addresses are handled appropriately. Here is an example from MySQL 5.5.12 on Windows 7
mysql> SELECT INET_ATON('127.0.0.1'), INET_ATON('127.1');
+------------------------+--------------------+
| INET_ATON('127.0.0.1') | INET_ATON('127.1') |
+------------------------+--------------------+
| 2130706433 | 2130706433 |
+------------------------+--------------------+
1 row in set (0.05 sec)
source
share