The first time I needed to have some kind of complex select statement, I started to pray about the ability to use regular expressions with mysql. Easy as it may be: use REGEXP ! For example: SELECT * FROM db.ip_addresses WHERE ip_address REGEXP '^192\.168\.0\.(133|135)$'; See the official documentation and details here .