SQL LIKE Operator

SQL LIKE Operator is used in WHERE Clause of SQL statement, to search for specific pattern in column. And the pattern we can place it in different formats. Here I’ll provide different types of formats that you can use in SQL LIKE Operator.

Syntax of SQL LIKE Operator in SELECT statement :

SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;

SQL LIKE Operator Examples

First example is if you want to filter a column starting with a letter or letters, then you can use ‘letters%’ in the statement.

In this below statement, results are retried based on names starting with letters.

SELECT column_name(s)
FROM table_name
WHERE name LIKE 's%';

Second example is if you want to filter a column containing some letters or words, then you can use words in between percentage symbols.

In this below statement, results are retrieved based on names contains letters or word sam.

SELECT column_name(s)
FROM table_name
WHERE name LIKE '%sam%';

Third example is if you want to filter a column ending with a letter or letters, then you can use ‘%s’ in the statement.

In this below statement, results are retried based on names ending with letters.

SELECT column_name(s)
FROM table_name
WHERE name LIKE '%s';

Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply:

x

Join My Facebook Group to Receive Coding Tutorial for Free

email-subsribe