IPV4_STRING_TO_NUM_OR_NULL
SinceVersion dev
IPV4_STRING_TO_NUM_OR_NULL
description
Syntax
BIGINT IPV4_STRING_TO_NUM_OR_NULL(VARCHAR ipv4_string)
Takes a string containing an IPv4 address in the format A.B.C.D (dot-separated numbers in decimal form). Returns a BIGINT number representing the corresponding IPv4 address in big endian.
notice
will return null if the input parameter is invalid ipv4 value
example
1. mysql> select ipv4_string_to_num_or_null('192.168.0.1');
2. +-------------------------------------------+
3. | ipv4_string_to_num_or_null('192.168.0.1') |
4. +-------------------------------------------+
5. | 3232235521 |
6. +-------------------------------------------+
7. 1 row in set (0.01 sec)
9. mysql> select str, ipv4_string_to_num_or_null(str) from ipv4_str;
10. +-----------------+---------------------------------+
11. |str | ipv4_string_to_num_or_null(str) |
12. +-----------------+---------------------------------+
13. | 0.0.0.0 | 0 |
14. | 127.0.0.1 | 2130706433 |
15. | 255.255.255.255 | 4294967295 |
16. | invalid | NULL |
17. +-----------------+---------------------------------+
18. 4 rows in set (0.01 sec)
keywords
IPV4_STRING_TO_NUM_OR_NULL, IP
