Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-08-24 10:49:02
forward
523 people have browsed it

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template