当前位置:网站首页>Complete review (including syntax) -- MySQL regular expressions
Complete review (including syntax) -- MySQL regular expressions
2022-06-26 01:25:00 【Mixed with bean curd and】
Complete review of regular expressions ( Including grammar )
– Regular expression data is from the previous chapter MyBingSchool In the library
use MyBingSchool;
– Student information sheet
SELECT * FROM Student;
– Subject list
select * from Cuosre;
– Score table
select * from Sorce;
– Teachers list
select * from Teacher;
– Regular expressions Operation cases
– ^ Matches the start of the input string With 1 Starting data
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '^1' ORDER BY s_brith ;
– ^ Matches the end of the input string With 9 Starting data
-- select s_sroce as ' fraction ' from Sorce WHERE s_sroce REGEXP '^9' ORDER BY s_sroce ;
select s_sroce as ' fraction ' from Sorce WHERE s_sroce REGEXP '9$' ORDER BY s_sroce ;
select s_name as ' full name ' from student WHERE s_name REGEXP ' Four $' ORDER BY s_name;
select s_name as ' full name ' from student WHERE s_name REGEXP '^[ Zhang ]| Two &' ORDER BY s_name;
– . Match any character .9 Here match any containing 9 The data of
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '.9' ORDER BY s_brith;
– .4 Here match any containing 4 The data of
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '.4' ORDER BY s_brith;
– | And ‘or’ similar perhaps Match, so
select s_name as ' full name ' from student WHERE s_name REGEXP ' Zhang San | The king 2 | Li Si ' ORDER BY s_name;
– Lookup table with 199 1996 1998 The data of ‘’=LIKE It has the function of fuzzy query conditions
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '199' ORDER BY s_brith ;
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '1996' ORDER BY s_brith ;
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '1998' ORDER BY s_brith ;
– Combine [] Matching condition | perhaps
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '199[6|8]' ORDER BY s_brith ;
– * Match previous subexpression zero or more times * Equivalent to {0,}
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '1*' ORDER BY s_brith ;
– Match previous subexpression one or more times + Equivalent to {1,}
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '1+' ORDER BY s_brith ;
– Combine ^ + Use
select s_sroce as ' fraction ' from Sorce WHERE s_sroce REGEXP '^9+' ORDER BY s_sroce ;
– {n} n Is a non negative integer . Matched definite n Time 9{2}
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '9{2}' ORDER BY s_brith ;
– {n,m} m and n All non negative integers among n <= m Least match n Times and at most m Time
– Insert data for easy demonstration {n,m}
INSERT INTO student VALUES (DEFAULT,' Liu tao ',' Woman ','1999-01-11');
– Auto increment cannot be used without setting default
– Modify the insert data according to the name
UPDATE student set s_id='06' WHERE s_name=' Liu tao ';
INSERT INTO student VALUES ('07',' Wang Tao ',' Woman ','1999-02-22');
INSERT INTO student VALUES ('08',' Xiao Xiao ',' Woman ','1888-08-18');
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '9{1,3}' ORDER BY s_brith ;
select s_brith as ' date of birth ' from student WHERE s_brith REGEXP '9{2,3}' ORDER BY s_brith ;
边栏推荐
猜你喜欢

远程增量同步神器rsync

“热帖”统计

数组中的第K个最大元素

Endnote IEEE Transactions on industrial electronics/tie/tpel reference format template

新库上线 | CnOpenDataA股上市公司IPO申报发行文本数据

在FreeBSD中安装MySQL数据库

Musk vs. jobs, who is the greatest entrepreneur in the 21st century

Implementation notes of least square fitting conic in stm32

Handling of @charset UTF-8 warning problems during vite packaging and construction;

Optimized three-dimensional space positioning method and its fast implementation in C language
随机推荐
Sqlserver is case sensitive
Native DOM vs. virtual DOM
ASP. Net cache cache usage
Msp430f5529lp official board (red) can not debug the problem
Nacos registry
[机缘参悟-30]:鬼谷子-内揵篇-同理心,站在对方的立场,拉近与对方的心理距离
. Net using access 2010 database
Radio boxes are mutually exclusive and can be deselected at the same time
Shengxin weekly issue 34
ETCD数据库源码分析——集群通信初始化
Comment promouvoir efficacement les produits
Computer network knowledge summary (interview)
[flower carving experience] 11 start esp32c3
如何有效地推廣產品
马斯克 VS 乔布斯,谁是21世纪最伟大的创业家
2022防爆电气操作证考试题库及模拟考试
The kth largest element in the array
数组中的第K个最大元素
Flex & Bison 开始
Error 65:access violation at 0x58024400: no 'read' permission