Hi all!
Ok, I have a MySQL log whose records each contain an IP (in addition to other fields) and I am wanting to remove those records where the IP matches my blacklist array.
$blacklist = array (
'192.168.1.1',
'192.168.0.',
);
Now, for a full IP (192.168.1.1) it is easy:
DELETE FROM [tablename] WHERE [fieldname] IN ('".implode("','", $blacklist)."')
But, how could I remove those records who's IP start with one of the values in the array? In other words, a wildcard as so: 192.168.0.*
In PHP this would be easy to just match the left substring of the IP in the record with that of the array value ('192.168.0.'), or eregi, etc
How can this be done the efficient MySQL way?
Thanks for any help!