ifred
asked on
Remove records from mysql
Hi,
I have a voting poll database that received some really odd votes, the records show some very strange IPs.
4,546 Guest 455.513.414.406/24 / April 2, 2012 @ 6:11 am
4,547 Guest 540.498.503.183/31 / April 2, 2012 @ 6:11 am
A valid vote looks like this:
4,545 Guest 99.232.208.242 / ###.cable.rogers.com April 2, 2012 @ 6:12 am
So i would like to run a sql query and search for all results that have these strange ip.
1) Can i run a sql command that will display the results of all strange IP addresses ?
2) Is there a REGEX sql command that that will search for invalid ip addresses ?
3) What would be the equiv. DELETE command to get rid of these queries.
Thaks,
I have a voting poll database that received some really odd votes, the records show some very strange IPs.
4,546 Guest 455.513.414.406/24 / April 2, 2012 @ 6:11 am
4,547 Guest 540.498.503.183/31 / April 2, 2012 @ 6:11 am
A valid vote looks like this:
4,545 Guest 99.232.208.242 / ###.cable.rogers.com April 2, 2012 @ 6:12 am
So i would like to run a sql query and search for all results that have these strange ip.
1) Can i run a sql command that will display the results of all strange IP addresses ?
2) Is there a REGEX sql command that that will search for invalid ip addresses ?
3) What would be the equiv. DELETE command to get rid of these queries.
Thaks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So, which if any or all of these values exist in the pollip_ip field?
4,546 Guest 455.513.414.406/24 / April 2, 2012 @ 6:11 am
4,547 Guest 540.498.503.183/31 / April 2, 2012 @ 6:11 am
4,545 Guest 99.232.208.242 / ###.cable.rogers.com April 2, 2012 @ 6:12 am
4,546 Guest 455.513.414.406/24 / April 2, 2012 @ 6:11 am
4,547 Guest 540.498.503.183/31 / April 2, 2012 @ 6:11 am
4,545 Guest 99.232.208.242 / ###.cable.rogers.com April 2, 2012 @ 6:12 am
ASKER
455.513.414.406/24
and
540.498.503.183/31
and
99.232.208.242
and
540.498.503.183/31
and
99.232.208.242
Perhaps a stupid question, but assuming ###.cable.rogers.com is in the host field, is there always a host when the IP is valid?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So you mean you want to delete the records were the host field is empty?
Try this.
DELETE FROM `wp_pollsip` WHERE `poll_host` = '';
Or this.
DELETE FROM `wp_pollsip` WHERE `poll_host` is null;
Try this.
DELETE FROM `wp_pollsip` WHERE `poll_host` = '';
Or this.
DELETE FROM `wp_pollsip` WHERE `poll_host` is null;
ASKER
Not really. Every record has an ip, and i am wondering if one would know a SQL statement i could use that will return all fields where wp_pollsip contains an invalid IP address.
Unfortunately I am not that good with Regex expressions.
Unfortunately I am not that good with Regex expressions.
So do you want to delete records with invalid IPs or validate the existing IPs?
ASKER
i want to delete records with invalid IP addresses. Usually they have a number higher than 255 in at least one of the octets, those are REALLY invalid.
No problem, I was trying to do something with regexp but with no luck, so when you posted the table structure I just thought using the host field might work, wishful thinking I suppose.
ASKER
While it could be one of the way to do this, it is probably not the best way to do it.
Let's see if anybody else can help and thanks anyway.
Let's see if anybody else can help and thanks anyway.
455.513.414.406/24
and
540.498.503.183/31
and
99.232.208.242
So the first two are invalid why? Because they contain '/xx' at the end?
If that's the case, simply delete from wp_pollsip where instr(poll_ip,'/') >0
and
540.498.503.183/31
and
99.232.208.242
So the first two are invalid why? Because they contain '/xx' at the end?
If that's the case, simply delete from wp_pollsip where instr(poll_ip,'/') >0
ASKER
The first two ones are invalid because these are not valid IP numbers, IP numbers are up to 255 in any octet.
An IP can't have something like /24 at the end either.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does MySQL support a regex substring command?
ASKER
There was not enough good answers, and my main point was still the main reason i solved my problem.
ASKER
2 pollip_qid varchar(10)
3 pollip_aid varchar(10)
4 pollip_ip varchar(100)
5 pollip_host varchar(200)
6 pollip_timestamp varchar(20
7 pollip_user tinytext utf8_general_ci
8 pollip_userid int(10)
pollip_ip is the filed with the ip in question.