October 2001
Beginner to intermediate
400 pages
7h 45m
English
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.
| < | 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 |
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'
Read now
Unlock full access