SQL LIKE Operator
Syntax
The LIKE operator in SQL is used to search for patterns in a column’s values. You can use wildcard characters such as % (zero or more characters) and _ (a single character) for flexible matching.
-- Match values containing a patternSELECT column1, column2FROM table_nameWHERE column1 LIKE 'pattern%';
-- Match values with a specific lengthSELECT column1, column2FROM table_nameWHERE column1 LIKE 'pattern_';Example
-- Match names starting with 'J'SELECT nameFROM employeesWHERE name LIKE 'J%';/* Output:| name ||------------|| John Doe || Jane Smith |*/
-- Match names ending with 'n'SELECT nameFROM employeesWHERE name LIKE '%n';/* Output:| name ||------------|| John Doe |*/
-- Match names with exactly 4 charactersSELECT nameFROM employeesWHERE name LIKE '____';/* Output:| name ||------|| Jane |*/