IPV6_STRING_TO_NUM_OR_NULL
SinceVersion dev
IPV6_STRING_TO_NUM_OR_NULL
description
Syntax
VARCHAR IPV6_STRING_TO_NUM_OR_NULL(VARCHAR ipv6_string)
The reverse function of IPv6NumToString, it takes an IP address String and returns an IPv6 address in binary format. If the input string contains a valid IPv4 address, returns its IPv6 equivalent.
notice
will return NULL if the input string is not a valid IP address
example
1. mysql> select hex(ipv6_string_to_num_or_null('1111::ffff'));
2. +-----------------------------------------------+
3. | hex(ipv6_string_to_num_or_null('1111::ffff')) |
4. +-----------------------------------------------+
5. | 1111000000000000000000000000FFFF |
6. +-----------------------------------------------+
7. 1 row in set (0.01 sec)
9. mysql> select hex(ipv6_string_to_num_or_null('192.168.0.1'));
10. +------------------------------------------------+
11. | hex(ipv6_string_to_num_or_null('192.168.0.1')) |
12. +------------------------------------------------+
13. | 00000000000000000000FFFFC0A80001 |
14. +------------------------------------------------+
15. 1 row in set (0.02 sec)
17. mysql> select hex(ipv6_string_to_num_or_null('notaaddress'));
18. +------------------------------------------------+
19. | hex(ipv6_string_to_num_or_null('notaaddress')) |
20. +------------------------------------------------+
21. | NULL |
22. +------------------------------------------------+
23. 1 row in set (0.02 sec)
keywords
IPV6_STRING_TO_NUM_OR_NULL, IP
