IS_IP_ADDRESS_IN_RANGE
IS_IP_ADDRESS_IN_RANGEβ
IS_IP_ADDRESS_IN_RANGE
Descriptionβ
Syntaxβ
BOOLEAN IS_IP_ADDRESS_IN_RANGE(STRING ip_str, STRING cidr_prefix)
Determine whether the IP (IPv4 or IPv6) address is included in the network represented by CIDR notation. If yes, return true; otherwise, return false.
Exampleβ
mysql> SELECT is_ip_address_in_range('127.0.0.1', '127.0.0.0/8');
+----------------------------------------------------+
| is_ip_address_in_range('127.0.0.1', '127.0.0.0/8') |
+----------------------------------------------------+
| 1 |
+----------------------------------------------------+
mysql> SELECT is_ip_address_in_range('::ffff:192.168.0.1', '::ffff:192.168.0.4/128');
+------------------------------------------------------------------------+
| is_ip_address_in_range('::ffff:192.168.0.1', '::ffff:192.168.0.4/128') |
+------------------------------------------------------------------------+
| 0 |
+------------------------------------------------------------------------+
mysql> SELECT is_ip_address_in_range('127.0.0.1', NULL);
+-------------------------------------------+
| is_ip_address_in_range('127.0.0.1', NULL) |
+-------------------------------------------+
| NULL |
+-------------------------------------------+
Keywordsβ
IS_IP_ADDRESS_IN_RANGE, IP