Home  >  Article  >  Database  >  What is the use of MySQL NOT LIKE operator?

What is the use of MySQL NOT LIKE operator?

王林
王林forward
2023-09-15 19:21:031024browse

MySQL NOT LIKE 运算符有什么用?

By using MySQL's NOT LIKE operator, we can check that a string with a specified pattern does not exist in another string. Its syntax is NOT LIKE specific_pattern.

specific_pattern is a string pattern that we don't want to find in another string.

Example

Suppose we have a table called 'student_info' which contains the names of students and we want to get those that do not contain the string pattern 'Ga' in their names Student details. This can be achieved with the 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 the wildcard character used with the NOT LIKE operator.

The above is the detailed content of What is the use of MySQL NOT LIKE operator?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete