Logo

K-Learn

SQL LIKE Operator

< Previous Next >

SQL LIKE operator is used to search for a specified pattern in a column. It is often used in conjunction with the SELECT statement to retrieve data from a table based on a certain pattern.

LIKE Syntax

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

For example,

SELECT name, email
FROM student
WHERE name LIKE 'J%';

OUTPUT

The above example,

This would retrieve all rows from the student table where the name column starts with the letter "J"

Example,

SELECT name, email
FROM student
WHERE name LIKE '%n';

OUTPUT

In this case

The % wildcard character matches any number of characters before the letter "n", so this query would retrieve all rows where the name column ends with the letter "n".


< Previous Next >