MySQueaL Resources

resources for mysql admins and developers who are squealing for help

More Resources

Main Doc Pages
Comments
MySQL columns: everywhere I look are tables and columns; life is filled with databases of information to be ordered and grouped. (Duomo, Milan, Italy)

INET_ATON( ) Function

This MySQL function converts an Internet Protocol (IP) address in dot-quad notation to its numeric equivalent.

hits past month: 34 ;  last updated: may 4, 2009 - 2:34am ;  parent: MySQL Math Functions

Syntax

INET_ATON(IP_address)

Explanation

This function converts an Internet Protocol (IP) address in dot-quad notation to its numeric equivalent. The function INET_NTOA( ) can be used to reverse the results.

Examples

SELECT INET_ATON('12.127.17.72')
AS 'AT&T';

+-----------+
| AT&T      |
+-----------+
| 209654088 |
+-----------+

This function is useful in sorting IP addresses that lexically might not sort properly. For instance, an address of 10.0.11.1 would come after 10.0.1.1 and before 10.0.2.1 under normal sort conditions in an ORDER BY clause.

Return to MySQL Math Functions page of our MySQL Documentation