
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How LIKE operator works with comparison operators for matching specific kinds of patterns of a string?
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)
- Related Articles
- How to use comparison operator for numeric string in MySQL?
- Display specific table names with MySQL LIKE Operator
- Perform element-wise comparison of two string arrays using a comparison operator in Numpy
- How to restrict MySQL `LIKE` operator to begin with specific characters?
- What is the use of comparison operators with MySQL subquery?
- Python Comparison Operators
- How to overload Python comparison operators?
- In MySQL, how IN() comparison function works?
- Finding matching records with LIKE in MongoDB?
- In MySQL, how does the precedence of ! operator in comparison with NOT operator depends upon HIGH_NOT_PRECEDENCE SQL mode?
- How does comparison operator work with date values in MySQL?
- How Ternary operator in PowerShell Works?
- Why we cannot use comparison operator(=) for getting the rows with NULL from a table?
- Resolve ‘multi update only works with $ operators’ in MongoDb?
- Chaining comparison operators in C#

Advertisements