How LIKE operator works with comparison operators for matching specific kinds of patterns of a string?

MySQLMySQLi Database

We can also use comparison operators in WHERE clause along with LIKE operator to get specific output. It is demonstrated in the following example −

Example

Suppose we want to get the names end with letter ‘v’ from a table but we do not want a specific name say ‘Gaurav’ in the result set then we need to use comparison operator along with LIKE operator 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)
raja
Updated on 06-Feb-2020 06:00:33

Advertisements