Skip to main content
Version: V1.0.0

IP2INT

Declaration

IP2INT('ip_addr')

Description

Converts the IP address ip_addr to an integer.

If the input IP address is in the format s1.s2.s3.s4, the calculation rule for the return value is:

s1 * 2^24^ + s2 * 2^16^ + s3 * 2^8^ + s4

Example

SELECT
IP2INT('0.0.0.1'),
HEX(IP2INT('0.0.0.1')),
HEX(IP2INT('1.0.0.0'))
\G
*************************** 1. row ***************************
IP2INT('0.0.0.1'): 1
HEX(IP2INT('0.0.0.1')): 1
HEX(IP2INT('1.0.0.0')): 1000000
1 row in set (0.001 sec)