Home  >  Article  >  Database  >  How can the LIKE operator be used with comparison operators to match a specific type of pattern on a string?

How can the LIKE operator be used with comparison operators to match a specific type of pattern on a string?

WBOY
WBOYforward
2023-08-24 10:49:02486browse

LIKE 运算符如何与比较运算符一起使用来匹配字符串的特定类型模式?

We can also use comparison operators as well as LIKE operator in WHERE clause to get specific output. The following example demonstrates -

Example

Suppose we want to get the names ending with letter 'v' from the table but we don't want the specific name 'Gaurav' in the result set , we need to use comparison operators and LIKE operators, as follows-

mysql> Select * from student where name like '%v'and name != 'gaurav';
+------+-------+---------+---------+--------------------+
| Id   | Name  | Address | Subject | year_of_admission  |
+------+-------+---------+---------+--------------------+
| 2    | Aarav | Mumbai  | History |              2010  |
+------+-------+---------+---------+--------------------+
1 row in set (0.00 sec)

The above is the detailed content of How can the LIKE operator be used with comparison operators to match a specific type of pattern on a string?. 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