加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php mysql查询首字母!= [a-z]

发布时间:2020-12-13 14:13:45 所属栏目:PHP教程 来源:网络整理
导读:SELECT * FROM dbname WHERE text = 'a%' (this can get all the `text` fields which begin with the letter "a".) 但是如何获得第一个字母的字段!= [a-z]? 例如: "hello" // this first letter begin as not range in a-zいけ // also first letter
SELECT * FROM dbname WHERE text = 'a%' 
(this can get all the `text` fields which begin with the letter "a".)

但是如何获得第一个字母的字段!= [a-z]?

例如:

"hello"  // this first letter begin as  not range in a-z
いけ  // also first letter not begin range in a-z
... 
may also have a white space as the first character.

那么如何使用php mysql查询来获取所有这些结果的第一个字母!= [a-z]?

试试这个:
SELECT * FROM dbname WHERE text REGEXP '^[^a-zA-Z]';

也就是说,如果您希望它不区分大小写(大写或小写).如果你想允许大写字母A-Z,那么只需使用:

SELECT * FROM dbname WHERE text REGEXP '^[^a-z]';

基本上,正则表达式表示匹配字符串开头没有字母a-z的任何字符串.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读