MySQL IS_IPV4() Function
In MySQL, the IS_IPV4()
function checks whether the given parameter is a valid IPv4 address.
IS_IPV4()
Syntax
Here is the syntax of the MySQL IS_IPV4()
function:
IS_IPV4(ip)
Parameters
ip
- Required. An IPv4 address to check.
Return value
The MySQL IS_IPV4()
function checks if the given parameter is a valid IPv4 address and returns 1
if it is, otherwise returns 0
.
If the argument is NULL
, the function will return NULL
.
IS_IPV4()
Examples
This example demonstrates the basic usage of IS_IPV4()
.
SELECT IS_IPV4('192.168.1.100'), IS_IPV4('192.168.1.300');
+--------------------------+--------------------------+
| IS_IPV4('192.168.1.100') | IS_IPV4('192.168.1.300') |
+--------------------------+--------------------------+
| 1 | 0 |
+--------------------------+--------------------------+
Here, since 192.168.1.300
is not a valid IPv4 address, IS_IPV4('192.168.1.300')
returned 0
.