第九章,用正则表达式进行搜索。

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_欢的更多相关文章

  1. 《mysql必知必会》学习_第10章_20180731_欢

    第10章,计算字段. P64 select concat (vend_name,'(',vend_country,')') from vendors order by vend_name; # 拼接, ...

  2. 《mysql必知必会》学习_第18章_20180807_欢

    第18章 全文本搜索 P121  #创建一个新表,对表的列进行定义,定义之后,MySQL自动维护该索引# create table productnotes ( note_id  int   NOT ...

  3. 《mysql必知必会》学习_第五章_20180730_欢

    使用的工具是wamp的Mysql. P29 select prod_name from products;  #在表products中选列prod_name,顺寻不是纯粹的随机,但是没有说明排列顺序, ...

  4. 《mysql必知必会》学习_第22章_20180809_欢

    第22章:使用视图,视图是虚拟的表,以表形式呈现的是你查询的结果.并不是说在数据库里面真的存在这个表,但是是真的存在这些数据. select cust_name,cust_contact from c ...

  5. 《mysql必知必会》学习_第20章_20180809_欢

    第20章:更新和删除数据 P140 update customers set_emails='elmer@fudd.com' where cust_id=10005; 更新多个列,用逗号隔开.注意被指 ...

  6. 《mysql必知必会》学习_第19章_20180809_欢

    第19章 插入数据 P132 insert into customers VALUES(NULL,'Pep E.Lapew','100 Main Street',,Los Angeles','CA', ...

  7. 《mysql必知必会》学习_第17章_20180807_欢

    第17章:组合查询 P114 select vend_id ,prod_id,prod_price from products where prod_price <=5 ; select ven ...

  8. 《mysql必知必会》学习_第16章_20180807_欢

    第16章:创建高级联结. P106 select concat(RTrim(vend_name),'(',RTrim(vend_country),')') as vend_title from ven ...

  9. 《mysql必知必会》学习_第15章_20180806_欢

    第15章:联结表 P98 外键:外键为某个表的一列A,同时这一列包含另一个表的主键值B(B属于A,等于或者小于的关系) P99 select vend_name,prod_name,prod_pric ...

随机推荐

  1. PAT 1008 数组元素循环右移问题 (20)(代码)

    1008 数组元素循环右移问题 (20)(20 分) 一个数组A中存有N(N&gt0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A ...

  2. 大数乘法java版

    import java.util.*; import java.math.*; public class NumMul{ public static void main(String args[]){ ...

  3. 10. pt-fk-error-logger

    pt-fk-error-logger DSN 外键约束相关的,不关注.

  4. h5解决移动端上滑卡顿问题

    select{ -webkit-overflow-scrolling: touch;/*解决移动端滑动卡顿问题*/ -webkit-transform: translateZ(0px);/*开启GPU ...

  5. linux 和 主机通信的另类方法

    偶然发现,linux可以从github上直接下载代码.这样就能用windows写好代码,直接给linux来跑了.很方便. 当然是因为我还不会配置网络来让linux和windows通信.弄了一个下午也没 ...

  6. 【Linux】ODBC安装

    ODBC介绍 ODBC是Open Database Connect 即开发数据库互连的简称,它是一个用于访问数据库的统一界面标准.ODBC引入一个公共接口以解决不同数据库潜在的不一致性,从而很好的保证 ...

  7. linux下设置mysql表名不区分大小写

    原文:http://blog.csdn.net/johnsonvily/article/details/6703902 1.Linux下mysql安装完后是默认:区分表名的大小写,不区分列名的大小写: ...

  8. 失踪的7(P1590&NOIP水题测试(2017082301))

    题目链接:失踪的7 水题,不解释. #include<bits/stdc++.h> using namespace std; int main(){ int t; scanf(" ...

  9. MySQL基准测试--innodb_buffer_pool_instances

    http://blog.chinaunix.net/uid-26896862-id-3345441.html 目的 根据现有硬件环境下,测试MySQL单实例下,在数据量小于innodb_buffer_ ...

  10. 关于Code Review

    为了保证代码质量,我们团队内部一直在推行Code Review.现在Code Review帮我们发现了很多代码的问题,提升了代码的可读性和质量,同时我们在Code Review上也花费了很多时间,有些 ...