Network Operators
The network operators that are built into PostgreSQL are useful for making comparisons between IP addresses. These operators function on INET and CIDR data types equally.
Listing
|
<
|
Less than
|
|
<=
|
Less than or equal to
|
|
=
|
Equals
|
|
>=
|
Greater than or equal to
|
|
>
|
Greater than
|
|
<>
|
Not equal
|
|
<<
|
Contained within
|
|
<<=
|
Contained within or equals
|
|
>>
|
Contains
|
|
>>=
|
Contains or equals
|
Notes/Examples
Use the following to find all the IP addresses less than the one specified:
SELECT * FROM computers WHERE ipaddr<'192.168.0.100'
Similarly, use the following to find all the IP addresses on the given subnet:
SELECT * FROM computers WHERE ipaddr<<'192.168.0.1/24'
|