INET_ATON( )

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

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

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.