常用正则sql 查询

1.查询字段是否手机号码

SELECT * FROM dym_member WHERE name REGEXP “^[1][35678][0-9]{9}$”

2.查询字段是否身份证号码

select * from table where card REGEXP ‘[0-9]{18}|[0-9]{17}X|[0-9]{15}’

3.删除字段不是手机号码的用户

DELETE from dym_member WHERE exists(select e.id from(SELECT id FROM dym_member WHERE name NOT REGEXP “^[1][35678][0-9]{9}$”)e)

PHP开发乐园(鼠标手)

你可能感兴趣的:(mysql)