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


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.

Updated on: 30-Jul-2019

40 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements