In MySQL, how to check for a pattern which is not present within an expression?

MySQLMySQLi Database

MySQL NOT RLIKE operator can be used to check for a pattern which is not present within an expression. The syntax for NOT RLIKE is as follows −

Syntax

NOT RLIKE Pat_not_for_match

Here Pat_not_for_match is the pattern which is not to be matched with the expression.

Example

mysql> Select Id, Name from Student WHERE Name NOT RLIKE '^H';
+------+---------+
| Id   | Name    |
+------+---------+
| 1    | Gaurav  |
| 2    | Aarav   |
| 20   | Gaurav  |
| 21   | Yashraj |
+------+---------+
4 rows in set (0.00 sec)

The above query finds the names from the ‘student’ table which do not have the pattern starts with ‘H’. ^ is a wildcard used with NOT RLIKE and signifies the beginning of the string.

raja
Published on 20-Feb-2018 11:44:33
Advertisements