MySQL LIKE Operator (original) (raw)

Last Updated : 25 Mar, 2026

The LIKE operator in MySQL is used to search for a specified pattern in a column. It is commonly used with the WHERE clause in SELECT statements to filter rows based on partial matches.

Syntax:

SELECT column1, column2, ... FROM table_name WHERE columnN LIKE pattern;

Working with the LIKE Operator

To understand the MySQL LIKE operator, we will first create a sample table and then run some queries to see how it works:

Screenshot-2026-03-25-142015

employees Table

Example 1: Search for Names Starting with 'J'

This example retrieves all employees whose names begin with the letter 'J' using the % wildcard.

**Query:

SELECT * FROM employees WHERE name LIKE 'J%';

**Output:

Screenshot-2026-03-25-142258

Example 2: Search for Names Ending with 'a'

This example finds employees whose names end with the letter 'a' using a wildcard at the beginning.

**Query:

SELECT * FROM employees WHERE name LIKE '%a';

**Output:

Screenshot-2026-03-25-142417

Example 3: Search for Names Containing 'ia'

This example filters employees whose names contain the substring 'ia' anywhere in the text.

**Query:

SELECT * FROM employees WHERE name LIKE '%ia%';

**Output:

Screenshot-2026-03-25-142529

Example 4: Search for Names with 'i' as the Second Character

This example selects employees whose names have 'i' as the second character using _ wildcard.

**Query:

SELECT * FROM employees WHERE name LIKE '_i%';

**Output:

Screenshot-2026-03-25-142658