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

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. 探索未知种族之osg类生物---器官初始化一

    我们把ViewerBase::frame()比作osg这类生物的肺,首先我们先来大概的看一下‘肺’长什么样子,有哪几部分组成.在这之前得对一些固定的零件进行说明,例如_done代表osg的viewer ...

  2. fedora 使用

    我们在这篇指南中将介绍安装Fedora 23工作站版本后要完成的一些实用操作,以便用起来更爽. 1.更新Fedora 23程序包 哪怕你可能刚刚安装/升级了Fedora 23,仍很可能会有需要更新的程 ...

  3. 2018 How to register and install LAUNCH ICARSCAN software ?

    2018 New Version ICARSCAN is available now! Here’s the instruction on how to install ICARSCAN softwa ...

  4. How To Configure SAMBA Server And Transfer Files Between Linux & Windows

    If you are reading this article it means you have a network at home or office with Windows and Linux ...

  5. 车站(NOIP1998)

    题目链接:车站 这一题,首先你要会推导,推到出式子后,就会像我一样简单AC. 给一张图: 这里,t是第二个车站上车人数. 有什么规律? 其实很好找.有如下规律: 第x车站的人数增量为第x-2车站的上车 ...

  6. gcc -ldl 选项作用

    如果你的程序中使用dlopen.dlsym.dlclose.dlerror 显示加载动态库,需要设置链接选项 -ldl 加载动态链接库,首先为共享库分配物理内存,然后在进程对应的页表项中建立虚拟页和物 ...

  7. 494. Target Sum - Unsolved

    https://leetcode.com/problems/target-sum/#/description You are given a list of non-negative integers ...

  8. 建库,建表,添加数据 SQL命令

    create database ssm default character set utf8; use ssm; create table flower( id int(10) primary key ...

  9. Servet-------JSTL标签库

    JSTL标签库 也可以和EL表达式配合使用 作用:   提高在Jsp中的逻辑代码的编写效率,使用标签..(对EL表达式的扩展)   使用: JSTL的核心标签库(重点) JSTL的SQL标签库 JST ...

  10. linux挂载ntfs格式的硬盘

    发生了一件辣眼睛的操作,一个现场应用升级,由于跨度很大,不敢直接动,就把现场的数据库dump拿回来,在公司做写升级测试. 于是,联系现场的工程师把数据库dump导出来,放到网盘弄回来. ------- ...