LIKE Operator in SQL

For Complete YouTube Video: Click Here

In this class, we will understand LIKE Operator in SQL.

We have already discussed some of the single value operators.

LIKE Operator in SQL

LIKE Operator can search through the rows of a database column for values that look like a pattern you describe.

Whenever we don’t know the exact value, we can match the pattern that it looks.

There are two Special Characters to denote which kind of matching to do. 

  1. % Wildcard (Anything is acceptable one character, hundreds of characters or no characters)
  2. _ Position Maker (Matches only one character)

Pattern Matching Examples

V% A value that starts with V and after that anything is accepted

_ _s% Two characters followed by ‘s,’ and after that, any character is accepted 

J%a First character should be J after that any character, and the last character should be a

Ran% First three characters should by Ran after that any number of characters

SQL Example using LIKE

To understand this we will consider the students as shown below.

LIKE Operator in SQL 1
LIKE Operator in SQL 1

More examples using LIKE in SQL

LIKE Operator in SQL 2
LIKE Operator 2
LIKE Operator in SQL 3
LIKE Operator 3
LIKE Operator in SQL 4
LIKE Operator 4