简体   繁体   中英

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. How can I look in my phone number field which numbers are not 10 digits and then delete them? 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}'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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