如何获取包含字母数字字符+空格的记录 [英] How to get records which contain alphaNumeric characters + white-spaces

查看:63
本文介绍了如何获取包含字母数字字符+空格的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取包含字母数字字符+空格的记录. OR 名称中的列表中的单个数字字符.

How to get records which contain alphaNumeric characters + white-spaces. OR At-list single numeric character in name.

即蜘蛛侠1,abc12 part1

i.e spiderman 1, abc12 part1

我做了什么.:

 select * from table t where t.name REGEXP '^[A-Za-z0-9]+$' 

但是它只会给出没有空格的记录:即abc123

but it will gives only records which dont have white space : i.e abc123

所以我也尝试过

  select * from table t where t.name REGEXP '^[A-Za-z0-9 ]+$' 

现在,它给了我一些不包含任何数字字符的记录.即abcdefg hij

Now, it gives me some records which does not contain any numeric characters. i.e abcdefg hij

推荐答案

SELECT *
FROM table
WHERE name REGEXP '^[a-zA-Z0-9 ]+$' AND name REGEXP '[0-9]'

更简单:

SELECT *
FROM table
WHERE name REGEXP '^[a-zA-Z0-9 ]*[0-9][a-zA-Z0-9 ]*$'

这篇关于如何获取包含字母数字字符+空格的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆