1. Initialize data DROP TABLE IF EXISTS `test_01`; CREATE TABLE `test_01` ( `id` int(0) NOT NULL, `stu` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'Student number', `user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'User', `km` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'Subject', `fs` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'Score', `time` datetime(0) NULL DEFAULT NULL COMMENT 'time', PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; INSERT INTO `test_01` VALUES (1, 'X0219001', '小三', '语文', '98', '2020-08-06 15:51:21'); INSERT INTO `test_01` VALUES (2, 'X0219001', '小三', '数学', '90', '2020-07-01 15:51:25'); INSERT INTO `test_01` VALUES (3, 'x0219001', '小三', '英语', '77', '2020-06-01 15:51:28'); INSERT INTO `test_01` VALUES (4, 'X0219002', '小二', '语文', '98', '2020-08-06 15:51:21'); 1. Basic character matching Matches student numbers that contain 'X' in the field. Case insensitive SELECT * FROM test_01 WHERE stu REGEXP 'X'; 2. '.' means matching any character If you need to match multiple characters, add more dots. SELECT * FROM test_01 WHERE stu REGEXP '.9001'; SELECT * FROM test_01 WHERE stu REGEXP '.02..0'; 3. '|' means to search for one of the two strings SELECT * FROM test_01 WHERE user REGEXP '二|四'; 4. '[ ]' matches any single character SELECT * FROM test_01 WHERE stu REGEXP '0[23]'; Here [23] is equivalent to [2|3], and one [] matches one character. Matching range 5. Matching special characters 1.\ escape character That is, escaping: all characters that have special meaning within a regular expression must be escaped in this way.
2.\ is also used to quote metacharacters
3. Match multiple instances
4. Matching Character Classes
This is the end of this article about the detailed usage of the MySQL comparison operator regular expression matching REGEXP. For more relevant MySQL regular expression matching REGEXP content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Detailed explanation of how Nginx works
>>: A brief discussion on the implementation principle of Webpack4 plugins
0. Introduction What is the ibdata1 file? ibdata1...
Definition and Usage The display property specifi...
The so-called container actually creates a readab...
1 Background JDK1.8-u181 and Tomcat8.5.53 were in...
Scenario You need to use the xshell tool to conne...
There are two types of Linux system time. (1) Cal...
MySQL slow log is a type of information that MySQ...
1. Search for redis image docker search redis 2. ...
1. Modify the firewall settings and open the corr...
1. Introduction As we all know, in the applicatio...
This article uses examples to illustrate the prin...
Table of contents 1. Why is JavaScript single-thr...
Table of contents Preface 1. Current gcc version ...
Preface: Docker port mapping is often done by map...
Optimizing and refining information is always the ...