SelectDB Cloud
SQL 手册
SQL 函数
IP Functions
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)

判断IP(IPv4或IPv6)地址是否包含在以CIDR表示法表示的网络中。如果是,则返回true,否则返回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

© 2023 北京飞轮数据科技有限公司 京ICP备2022004029号 | Apache、Apache Doris 以及相关开源项目名称均为 Apache 基金会商标