Breaking News
yeni film izle hd film seyret film izle

Like clause

Like clause is used as condition in SQL query. Like clause compares data with an expression using wildcard operators. It is used to find similar data from the table.


Wildcard operators

There are two wildcard operators that are used in like clause.

  • Percent sign % : represents zero, one or more than one character.
  • Underscore sign _ : represents only one character.

Example of LIKE clause

Consider the following Student table.

s_id s_Name age
101 Adam 15
102 Alex 18
103 Abhi 17
SELECT * from Student where s_name like 'A%';

The above query will return all records where s_name starts with character ‘A’.

s_id s_Name age
101 Adam 15
102 Alex 18
103 Abhi 17

Example

SELECT * from Student where s_name like '_d%';

The above query will return all records from Student table where s_name contain ‘d’ as second character.

s_id s_Name age
101 Adam 15

Example

SELECT * from Student where s_name like '%x';

The above query will return all records from Student table where s_name contain ‘x’ as last character.

s_id s_Name age
102 Alex 18