LIKE Operator with Comparison Operators in SQL



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)
Updated on: 2020-02-06T06:00:33+05:30

106 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements