开发者

MySQL query to remove certain email address, all follow similar pattern

Wondered if someone could help me write a MySQL query. I noticed in my email database I have a huge amount of users who got past my automated entry checks who I want to flag. They are all of the form abcdef123@hotmail.com where abcdef are random names of variable length, then a 3 digit number.

I have a field in my table called fld_bad, which I want to change to 1 in the query.

开发者_如何转开发

So something like

UPDATE tbl_users SET fld_bad = "1" WHERE fld_email ..... 

Obviously the ..... is where my knowledge is failing me!


you can use the mysql regexp command to do this

http://dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_regexp

UPDATE tbl_users SET fld_bad = "1" WHERE fld_email REGEXP '[A-Za-z]+[0-9]{3}@hotmail\\.com' = 1;


You can use:

UPDATE tbl_users 
SET fld_bad = "1" 
WHERE fld_email REGEXP '[[:alpha:]]+[[:digit]]{3}@hotmail\\.com'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜