MySQL IS_IPV4_MAPPED() Function

In MySQL, the IS_IPV4_MAPPED() function checks whether a numeric IPv6 address is an IPv4-mapped IPv6 address.

IS_IPV4_MAPPED() Syntax

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

IS_IPV4_MAPPED(ip)

Parameters

ip
Required. An IPv6 address to check.

Return value

The MySQL IS_IPV4_MAPPED() function checks whether a numeric IPv6 address is an IPv4-mapped IPv6 address, and returns 1 if it is, otherwise returns 0.

The format of an IPv4-mapped IPv6 address is: ::ffff:IPv4-address, for example: ::ffff:192.168.1.10.

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

IS_IPV4_MAPPED() Examples

This example demonstrates the basic usage of IS_IPV4_MAPPED().

SELECT
    IS_IPV4_MAPPED(INET6_ATON('::192.168.1.100')),
    IS_IPV4_MAPPED(INET6_ATON('::ffff:192.168.1.100'));
+-----------------------------------------------+----------------------------------------------------+
| IS_IPV4_MAPPED(INET6_ATON('::192.168.1.100')) | IS_IPV4_MAPPED(INET6_ATON('::ffff:192.168.1.100')) |
+-----------------------------------------------+----------------------------------------------------+
|                                             0 |                                                  1 |
+-----------------------------------------------+----------------------------------------------------+

Here, since ::192.168.1.100 is not an IPv4-mapped IPv6 address, IS_IPV4_MAPPED(INET6_ATON('::192.168.1.100')) returned 0.