《mysql必知必会》学习_第9章_20180731_欢
第九章,用正则表达式进行搜索。
P52
select prod_name from products where prod_name regexp '1000' order by prod_name; #regexp后面所跟着的文字为正则表达式,regexp匹配任何的字符#

select prod_name from products where prod_name regexp '.000' order by prod_name; #点(.)表示匹配任何的字符#


LIKE和REGEXP的区别,LIKE匹配的是整个列,REGEXP匹配的是一个列的完整或者一段,例如,like ‘huan’ 返回 huan ;而regexp ‘huan’返回 ‘huan 也返回 xxhuanxx ;当LIKE加上通配符的时候,可以相当于EXGEXP。
P54
select prod_name from products where prom_name regexp '1000|2000' order by prod_name ; #符号竖直杠(|)功能相当于or,但此处不可用or 替代#

P55
select prod_name from products where prod_name regexp '[123] ton' order by prod_name ; #[123] ton 表示匹配的字段含有 1 ton或者2 ton或者3 ton , [ ]是or是另一种形式的or语句,和下面的语句表达同样的意思#

P56
[0123456789] 表示匹配0到9,可以用[0-9]简化。
select prod_name from products where prod_name regexp '[1-5] ton' order by prod_name; #正则表达式检索 x1 tonx 到 x5 tonx #

select vend_name from products where vend_name regexp '.' order by vend_name; #点(.)表示匹配任何字符,所以返回的结果是每个行都被检索出来。#


P57
select vend_name from products where vend_name regexp '\\.' order by vend_name; #点(.)表示匹配任何字符,所以返回的结果是每个行都被检索出来。当要检索点. 时候,\\为前导,表示查找,\\.表示查找.#

注意:匹配斜杠时候,是regexp '\\\' 。
P61
select 'hello' regexp from '[0-9]'; #可以在自定义的一段字段里面搜索,不用指定表,返回0表示结果为 hello中没有数字#

注意: 当编写语句时候,’ ‘没有对应上,就算已经用;,还是表示该语句没有结束,可以其他符号也会像这个一样有始有终吧,我暂时没发现其他的。如下图#

《mysql必知必会》学习_第9章_20180731_欢的更多相关文章
- 《mysql必知必会》学习_第10章_20180731_欢
		第10章,计算字段. P64 select concat (vend_name,'(',vend_country,')') from vendors order by vend_name; # 拼接, ... 
- 《mysql必知必会》学习_第18章_20180807_欢
		第18章 全文本搜索 P121 #创建一个新表,对表的列进行定义,定义之后,MySQL自动维护该索引# create table productnotes ( note_id int NOT ... 
- 《mysql必知必会》学习_第五章_20180730_欢
		使用的工具是wamp的Mysql. P29 select prod_name from products; #在表products中选列prod_name,顺寻不是纯粹的随机,但是没有说明排列顺序, ... 
- 《mysql必知必会》学习_第22章_20180809_欢
		第22章:使用视图,视图是虚拟的表,以表形式呈现的是你查询的结果.并不是说在数据库里面真的存在这个表,但是是真的存在这些数据. select cust_name,cust_contact from c ... 
- 《mysql必知必会》学习_第20章_20180809_欢
		第20章:更新和删除数据 P140 update customers set_emails='elmer@fudd.com' where cust_id=10005; 更新多个列,用逗号隔开.注意被指 ... 
- 《mysql必知必会》学习_第19章_20180809_欢
		第19章 插入数据 P132 insert into customers VALUES(NULL,'Pep E.Lapew','100 Main Street',,Los Angeles','CA', ... 
- 《mysql必知必会》学习_第17章_20180807_欢
		第17章:组合查询 P114 select vend_id ,prod_id,prod_price from products where prod_price <=5 ; select ven ... 
- 《mysql必知必会》学习_第16章_20180807_欢
		第16章:创建高级联结. P106 select concat(RTrim(vend_name),'(',RTrim(vend_country),')') as vend_title from ven ... 
- 《mysql必知必会》学习_第15章_20180806_欢
		第15章:联结表 P98 外键:外键为某个表的一列A,同时这一列包含另一个表的主键值B(B属于A,等于或者小于的关系) P99 select vend_name,prod_name,prod_pric ... 
随机推荐
- string+和stringbuffer的速度比较
			public class Main{ public static void main(String[] args){ /* 1 */ String string = "a" + & ... 
- opencv中imread第二个参数的意义
			文档中是这么写的: Flags specifying the color type of a loaded image: CV_LOAD_IMAGE_ANYDEPTH - If set, return ... 
- unbutton 内部title label多行显示
			dateBtn1.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; [dateBtn1 setTitle: @第一行\n第二行" f ... 
- 没加载redis类,却可以实例化redis
			原因:phpinfo里面已有redis扩展 
- PhpStorm 为 Laravel 搭建 PhpUnit 单元测试环境
			1.PhpStorm 中打开项目的路径为 Laravel 安装的根目录 2.点击右下角 EventLog 提示按钮, 初始化 Composer 的设置 3.打开单元单测试示例类,按提示点击 Fix . ... 
- @1-4使用Xpath解析豆瓣短评
			使用Xpath解析豆瓣短评 Python爬虫(入门+进阶) DC学院 本节课程主要介绍解析神器Xpath是什么.Xpath如何安装及使用,以及使用实际的例子讲解Xpath如何解析豆瓣短评的网页 ... 
- PHP TP 生成二维码
			vendor('phpqrcode.phpqrcode'); $value = "http://www.baidu.com";//二维码内容 $errorCorrectionLev ... 
- php file_get_contents 使用3法
			<?php //GET function http_get($url, $params){ return file_get_contents($url.'?'.http_build_query( ... 
- ubuntu14上安装nltk
			安装nltk 1)在buntu终端命令键入:wget https://bootstrap.pypa.io/ez_setup.py,下载ez_setup.py. 2)下载完成后后,键入:sudo py ... 
- CentOS下利用mysqlbinlog恢复MySQL数据库
			如果不小心对数据库进行误操作,而又没有及时备份怎么办?这恐怕是广大的coder经常遇到的一类问题.我今天就因为不小心删除了某个数据库,但最后的备份是1个礼拜前的,唯一能解决的办法就是通过mysqlbi ... 
