The SQL LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
It allows you to search for data that matches a specified pattern
The pattern can include two wildcard characters:
- % (percent sign) - matches zero, one, or multiple characters
- _ (underscore) - matches a single character
SELECT * FROM employees
WHERE name LIKE 'R%';
Query Will Search Name From Employees Table That Start With “R” And Return All Name Start With “R”
SELECT * FROM employees
WHERE name LIKE '%R';
Query Will Search Name From Employees Table That End With “R” And Return All Name End With “R”
SELECT * FROM employees
WHERE name LIKE '%R%';
Query Will Search Name From Employees Table That Have “R” In Any Position And Return All Name Having “R” In Any Position
SELECT * FROM employees
WHERE name LIKE '%A_';
Query Will Search Name From Employees Table Second Last Letter Of Name Is “A” Return All Name Which Having Second Last Letter With “A”