Home > Database > Mysql Tutorial > body text

What different wildcard characters can be used with the MySQL RLIKE operator?

WBOY
Release: 2023-09-16 08:57:16
forward
1430 people have browsed it

MySQL RLIKE 运算符可以使用哪些不同的通配符?

Using the wildcard character of the RLIKE operator can save a lot of effort when we write queries that find a certain pattern (regular expression) in a string. The wildcard used by RLIKE is:

  • ^ - It represents the BEGINING of the string. In other words, when we use this wildcard with RLIKE operator, it will find the pattern starting with a specific string written after the ^ wildcard

Example

 mysql> Select Id, Name from Student WHERE Name RLIKE '^H';
 +------+---------+
 | id   | Name    |
 +------+---------+
 | 15   | Harshit |
 +------+---------+
 1 row in set (0.00 sec)
Copy after login
  • $ - It indicates the end of the string. In other words, when we use this wildcard with the RLIKE operator, it will find the pattern ending with the specific string written after the $ wildcard.

Example

mysql> Select Id, Name from Student WHERE Name RLIKE 'v$';
+------+--------+
| Id   | Name   |
+------+--------+
| 1    | Gaurav |
| 2    | Aarav  |
| 20   | Gaurav |
+------+--------+
3 rows in set (0.00 sec)

Copy after login
  • | - means "or". In other words, when we use this wildcard with RLIKE operator, it will find strings that have substrings written with |. Wildcard.

Example

mysql> Select Id, Name from Student WHERE Name RLIKE 'Gaurav|raj';
+------+---------+
| Id   | Name    |
+------+---------+
| 1    | Gaurav  |
| 20   | Gaurav  |
| 21   | Yashraj |
+------+---------+
3 rows in set (0.00 sec)
Copy after login

The above is the detailed content of What different wildcard characters can be used with the MySQL RLIKE operator?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template