mysql regexp 表达式
mysql> select * from test;
+----+----------+-------+-----------+
| id | name | score | subject |
+----+----------+-------+-----------+
| | xiaoming | | shuxue |
| | xiaohong | | shuxue |
| | xiaohong | | english |
| | xiaohong | | physics |
| | xiaohong | | astronaut |
| | xiaoming | | physics |
| | xiaoming | | astronaut |
| | xiaoming | | english |
| | xiaobai | | astronaut |
| | xiaobai | | english |
| | xiaobai | | physics |
| | xiaobai | | shuxue |
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+----------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp "xiaohei";
+----+---------+-------+-----------+
| id | name | score | subject |
+----+---------+-------+-----------+
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+---------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp "hei";
+----+---------+-------+-----------+
| id | name | score | subject |
+----+---------+-------+-----------+
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+---------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp ".hei";
+----+---------+-------+-----------+
| id | name | score | subject |
+----+---------+-------+-----------+
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+---------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp ".he";
+----+---------+-------+-----------+
| id | name | score | subject |
+----+---------+-------+-----------+
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+---------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp "hei";
+----+---------+-------+-----------+
| id | name | score | subject |
+----+---------+-------+-----------+
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+---------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp "hei|bai";
+----+---------+-------+-----------+
| id | name | score | subject |
+----+---------+-------+-----------+
| | xiaobai | | astronaut |
| | xiaobai | | english |
| | xiaobai | | physics |
| | xiaobai | | shuxue |
| | xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+---------+-------+-----------+
rows in set (0.00 sec)
mysql> select * from test;
+----+------------+-------+-----------+
| id | name | score | subject |
+----+------------+-------+-----------+
| | xiaoming | | shuxue |
| | xiaohong | | shuxue |
| | xiaohong | | english |
| | xiaohong | | physics |
| | xiaohong | | astronaut |
| | xiaoming | | physics |
| | xiaoming | | astronaut |
| | xiaoming | | english |
| | xiaobai | | astronaut |
| | .2xiaobai | | english |
| | .2xiaobai | | physics |
| | 3xiaobai | | shuxue |
| | 123xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+------------+-------+-----------+
rows in set (0.00 sec) mysql> update test set name="123xiaohei" where id=;
Query OK, row affected (0.01 sec)
Rows matched: Changed: Warnings: mysql> select * from test where name regexp '[[:digit:]]{3}';
+----+------------+-------+-----------+
| id | name | score | subject |
+----+------------+-------+-----------+
| | 123xiaohei | | astronaut |
+----+------------+-------+-----------+
row in set (0.00 sec) mysql> select * from test where name regexp "^xiao";
+----+----------+-------+-----------+
| id | name | score | subject |
+----+----------+-------+-----------+
| | xiaoming | | shuxue |
| | xiaohong | | shuxue |
| | xiaohong | | english |
| | xiaohong | | physics |
| | xiaohong | | astronaut |
| | xiaoming | | physics |
| | xiaoming | | astronaut |
| | xiaoming | | english |
| | xiaobai | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | xiaohei | | english |
+----+----------+-------+-----------+
rows in set (0.00 sec) mysql> update test set name=".12xiaohei" where id=;
Query OK, row affected (0.00 sec)
Rows matched: Changed: Warnings: mysql> select * from test;
+----+------------+-------+-----------+
| id | name | score | subject |
+----+------------+-------+-----------+
| | xiaoming | | shuxue |
| | xiaohong | | shuxue |
| | xiaohong | | english |
| | xiaohong | | physics |
| | xiaohong | | astronaut |
| | xiaoming | | physics |
| | xiaoming | | astronaut |
| | xiaoming | | english |
| | xiaobai | | astronaut |
| | .2xiaobai | | english |
| | .2xiaobai | | physics |
| | 3xiaobai | | shuxue |
| | 123xiaohei | | astronaut |
| | xiaohei | | shuxue |
| | xiaohei | | physics |
| | .12xiaohei | | english |
+----+------------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp "[[:digit:]\\.]";
+----+------------+-------+-----------+
| id | name | score | subject |
+----+------------+-------+-----------+
| | .2xiaobai | | english |
| | .2xiaobai | | physics |
| | 3xiaobai | | shuxue |
| | 123xiaohei | | astronaut |
| | .12xiaohei | | english |
+----+------------+-------+-----------+
rows in set (0.00 sec) mysql> select * from test where name regexp "^[[:digit:]\\.]";
+----+------------+-------+-----------+
| id | name | score | subject |
+----+------------+-------+-----------+
| | .2xiaobai | | english |
| | .2xiaobai | | physics |
| | 3xiaobai | | shuxue |
| | 123xiaohei | | astronaut |
| | .12xiaohei | | english |
+----+------------+-------+-----------+
rows in set (0.00 sec)
mysql regexp 表达式的更多相关文章
- 测量MySQL的表达式和函数的速度
测量MySQL的表达式和函数的速度,可以调用benchmark()函数.语法格式是benchmark(loop_count,expr).运行的返回值是0,但是mysql会打印一行显示语句大概要执行多长 ...
- mysql regexp用法
正则表达式作用是匹配方本,将一个模式(正则表达式)与一个文本串进行比较. MySQL用WHERE子句对正则表达式提供了初步的支持,允许你指定用正则表达式过滤SELECT检索出的数据. MySQL仅支持 ...
- MySQL where 表达式
where 条件表达式 对记录进行过滤,如果没有指定where子句,则显示所有记录. 在where表达式中,可以使用MySQL支持的函数或运算符.
- MySQL SELECT表达式的执行顺序是从左往右依次执行
例子如下:(确保这几个变量都是初次使用,因为mysql的用户自定义变量会在整个连接session中存在) ,,; +--------+-------+---------+-------+ | +--- ...
- mysql查询表达式解析
1.mysql> SHOW COLUMNS FROM users;+----------+----------------------+------+-----+---------+------ ...
- MySQL中REGEXP正则表达式使用大全
REGEXP在mysql是用来执行正则表达式的一个函数 像php中的preg之类的函数了,regexp正则函数如果只是简单的查询使用like即可,但复杂的还是需要使用regexp了,下面我们来看看. ...
- Thinkphp用exp表达式执行mysql语句,查询某字段不为空is not null,自动增值
Thinkphp用exp表达式执行mysql语句,查询某字段不为空is not null,自动增值 Thinkphp 的文档经常不够完整的表达MYSQL的各种组合,is not null在thinkp ...
- Thinkphp中查询复杂sql查询表达式,如何表达MYSQL中的某字段不为空is not null?
Thinkphp中查询复杂sql查询表达式,如何表达MYSQL中的某字段不为空is not null?先上两种实现方式的实例:$querys["house_type_image"] ...
- mysql 函数编程大全(持续更新)
insert ignore insert ignore表示,如果中已经存在相同的记录,则忽略当前新数据 如果您使用一个例如“SET col_name = col_name + 1”的赋值,则对位于右侧 ...
随机推荐
- Tomcat组件梳理—Service组件
Tomcat组件梳理-Service组件 1.组件定义 Tomcat中只有一个Server,一个Server可以用多个Service,一个Service可以有多个Connector和一个Contain ...
- Python进阶----SOCKET套接字基础, 客户端与服务端通信, 执行远端命令.
Python进阶----SOCKET套接字基础, 客户端与服务端通信, 执行远端命令. 一丶socket套接字 什么是socket套接字: 专业理解: socket是应用层与TCP/IP ...
- Python进阶----类的结构(公有成员 , 私有成员(私有属性,私有方法),类方法,静态方法,属性) ,isinstance 和issubcalss ,元类(type())
Python进阶----类的结构(公有成员 , 私有成员(私有属性,私有方法),类方法,静态方法,属性) ,isinstance 和issubcalss ,元类(type()) 一丶类的结构细分 ...
- 【转载】C#中Convert.ToSingle方法将字符串转换为Float类型
在C#编程过程中,可以使用Convert.ToSingle方法将字符串或者其他可转换为数字的对象变量转换为float类型,Convert.ToSingle方法有多个重载方法,最常使用的一个方法将字符串 ...
- git拉取单个子目录
初始化一个目录cron(需要拉取的的是code下的cron目录) git init cron 进入目录cd cron/ git remote add -f code ssh://git@192.168 ...
- .gitignore详解(附上eclipse的java项目的 .gitignore文件)
今天讲讲Git中非常重要的一个文件――.gitignore. 首先要强调一点,这个文件的完整文件名就是“.gitignore”,注意最前面有个“.”.这样没有扩展名的文件在Windows下不太好创建, ...
- webapi之owin的oauth2.0密码模式_01概述
一般在webapi接口中,为了防止接口被随意调用,都会验证用户身份. 然而不能每次调用接口都需要用户输入用户名密码来验证,这时就需要授权颁发令牌了,持有令牌就可以访问接口,接口也能验证令牌身份. 简单 ...
- beta版本——第二次冲刺
第二次冲刺 (1)SCRUM部分☁️ 成员描述: 姓名 唐财伟 完成了哪个任务 搭建Nginx 花了多少时间 3h 还剩余多少时间 0h 遇到什么困难 解决端口冲突,启动报错等问题 这两天解决的进度 ...
- X2E车载数据记录仪
随着智能驾驶及网联技术深入应用,汽车中传输的数据量与日俱增,包括多种总线数据.视频数据.雷达数据.定位数据等等.据悉,高级别智能驾驶汽车中每秒传输的总线数据就达到G比特级别.而从产品开 ...
- c语言实现基本的数据结构(二) 链表(包括链表的三种简单排序算法)
#include "stdafx.h" #include <stdlib.h> //创建一个节点,data为value,指向NULL Node* Create(int ...