How to use LIKE on inet field in Postgres How to use LIKE on inet field in Postgres postgresql postgresql

How to use LIKE on inet field in Postgres


Use subnet operators for such queries. '88.99.0.0/16' should do it :

SELECT * FROM users WHERE ip << inet '88.99.0.0/16';


Another option which worked for me if you want to do a string comparison is this:

SELECT * FROM users WHERE TEXT(ip) LIKE '88.99.%';

although it will be less efficient than "How to use LIKE on inet field in Postgres".

Reference: https://www.postgresql.org/docs/8.2/static/functions-net.html