What is the use of MySQL NOT LIKE operator?

MySQLMySQLi Database

With the help of MySQL NOT LIKE operator, we can check non-presence of a string of specified pattern within another string. Its syntax is NOT LIKE specific_pattern.

Specific_pattern is the pattern of string we do not want to find out within another string.

Example

Suppose we have a table named ‘student_info’ having names of the students and we want to get the details of all those students which are not having pattern of string ‘Ga’ within their names. It can be done with the help of following MySQL query −

mysql> Select * from Student_info WHERE name NOT LIKE '%Ga%';
+------+---------+----------+-----------+
| id   | Name    | Address  | Subject   |
+------+---------+----------+-----------+
| 101  | YashPal | Amritsar | History   |
| 125  | Raman   | Shimla   | Computers |
+------+---------+----------+-----------+
2 rows in set (0.05 sec)

In the above example, the ‘%’ symbol is a wildcard used along with NOT LIKE operator.

raja
Published on 21-Feb-2018 06:36:44
Advertisements