简体   繁体   English

如何检查10位数字

[英]how to check for 10 digits

I have a phone number field. 我有一个电话号码字段。 To be a valid phone number there has to be only 10 digits. 要成为有效的电话号码,只能输入10位数字。 How can I look in my phone number field which numbers are not 10 digits and then delete them? 如何在我的电话号码字段中查找哪些数字不是10位数字,然后将其删除? thanks 谢谢

I believe you should validate it first before inserting the phone number into the database. 我相信您应该先验证它,然后再将电话号码插入数据库。

Although i believe that it is possible if you use 虽然我相信如果您使用

Delete from Table where (Select statement here);

But it's not going to reflect well in your overall program, in terms of performance and reusability 但是就性能和可重用性而言,它不能很好地反映在您的整个程序中

假设您在该字段中没有任何“-”,

mysql> DELETE FROM Table WHERE PHONE_NUM NOT RLIKE '[0-9]{10}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM