检查字符串是否包含数字 [英] Check if a string contains numbers
本文介绍了检查字符串是否包含数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查MySQL字段中的字符串是否包含数字,然后将其删除?
How do I check if a string in a MySQL field contains a number then delete them?
表格示例:
tbl_tags
-------------
| id | tag |
-------------
| 1 | hello |
| 2 | hello2 |
| 3 | 2hello |
| 4 | hel3lo |
-------------
我能想到的唯一方法是分别计算每个数字并使用 LIKE'%1%'或LIKE'%2%'等.但是,必须有一种更简单的方法吗?>
The only way I can think of is to do each number individually and use LIKE '%1%' OR LIKE '%2%' etc. But there must be an easier way?
推荐答案
查看 MySQL Regex方法.像下面这样的东西应该起作用.
Check out the MySQL Regex methods. Something like the following should work.
SELECT * FROM table WHERE tag REGEXP '[0-9]'
这篇关于检查字符串是否包含数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文