MySQL INET_NTOA() Function

In MySQL, the INET_NTOA() function converts a specified numeric IP in network byte order to an IP address in a.b.c.d form.

The INET_NTOA() function is the inverse of the INET_ATON() function.

INET_NTOA() Syntax

Here is the syntax of the MySQL INET_NTOA() function:

INET_NTOA(numeric_ip)

Parameters

numeric_ip
Required. A numeric IP in network byte order.

Return value

The MySQL INET_NTOA() function converts a specified numeric IP in network byte order to an IP address in a.b.c.d form.

If the parameter is a non-numeric, the function will try to convert the parameter to a number before converting it to an IP address. If the parameter cannot be converted to a number, the function will return 0.0.0.0.

If the parameter is NULL, the function will return NULL.

INET_NTOA() Examples

Here is a common examples of INET_NTOA().

SELECT
    INET_NTOA(3232235876),
    INET_NTOA(0),
    INET_NTOA('100abc'),
    INET_NTOA('abc100'),
    INET_NTOA(NULL);
+----------------------------+
| INET_ATON('192.168.1.100') |
+----------------------------+
|                 3232235876 |
+----------------------------+