《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 ...
随机推荐
- 主机在无线网络的情况下,设置centos7.2虚拟机网络联通
1.vmvare中,编辑-虚拟网络编辑器 2.虚拟机设置 3.进入linux登录后 输入nmtui 4激活连接 5大功告成,输入ping www.baidu.com 发现ping通了
- Android.Tools.Eclipse hangs at the Android SDK Content Loader
Eclipse hangs at the Android SDK Content Loader http://stackoverflow.com/questions/13489141/eclipse- ...
- javascript数组中数字和非数字下标的区别(转)
http://blog.csdn.net/qq_27461663/article/details/52014911 考完试后闲来无事,想起好多天没写js了,于是打算实践一下最近看到的一些好玩的点子.结 ...
- Getting svn to ignore files and directories
August 27, 2013Software Developmentresources, subversion, svn, tutorial, version control Who knew it ...
- 如何用xx-net上youtube
1.下载https://github.com/XX-net/XX-Net/blob/master/code/default/download.md 里面的稳定版本 2.下载chrome.百度chr ...
- Vue 汇总
1.右键菜单(防止默认行为) @contextmenu.native.prevent="rightClick()"
- gcc -ldl 选项作用
如果你的程序中使用dlopen.dlsym.dlclose.dlerror 显示加载动态库,需要设置链接选项 -ldl 加载动态链接库,首先为共享库分配物理内存,然后在进程对应的页表项中建立虚拟页和物 ...
- NOIP 2017 d2t2 70points
革命之路漫漫 第一次尝试 40points spfa #include <bits/stdc++.h> #define read read() using namespace std; i ...
- 2019.02.07 bzoj4784: [Zjoi2017]仙人掌(仙人掌+树形dp)
传送门 题意:给一个无向连通图,问给它加边形成仙人掌的方案数. 思路: 先考虑给一棵树加边形成仙人掌的方案数. 这个显然可以做树形dp. fif_ifi表示把iii为根的子树加边形成仙人掌的方案数. ...
- 2018.11.01 NOIP训练 梭哈(模拟)
传送门 这题貌似不考智商啊. 直接按题意写就可以了. 事实上把牌从小到大排序之后写起来很舒服的. 然后就是有些地方可以人脑减代码量和判断次数. (提示:满堂红和某几种同类型的牌的大小判断) 然后注意A ...