TO_IPV4_OR_DEFAULT
TO_IPV4_OR_DEFAULTβ
TO_IPV4_OR_DEFAULT
Descriptionβ
Syntaxβ
IPV4 TO_IPV4_OR_DEFAULT(STRING ipv4_str)
Same as to_ipv4, but if the IPv4 address has an invalid format, it returns 0.0.0.0 (0 as IPv4).
Noticeβ
If input is NULL, return 0.0.0.0 (0 as IPv4).
Exampleβ
mysql> select to_ipv4_or_default('.');
+-------------------------+
| to_ipv4_or_default('.') |
+-------------------------+
| 0.0.0.0 |
+-------------------------+
mysql> select to_ipv4_or_default(NULL);
+--------------------------+
| to_ipv4_or_default(NULL) |
+--------------------------+
| 0.0.0.0 |
+--------------------------+
Keywordsβ
TO_IPV4_OR_DEFAULT, IP