What is the LIKE operator in SQL?
Why Interviewers Ask This
This is a classic screening question for MySQL / SQL roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. Two wildcard characters: % — represents zero or more characters; _ — represents exactly one character. Examples: WHERE name LIKE "Jo%" — matches "John", "Joe", "Jonathan" (starts with Jo); WHERE email LIKE "%@gmail.com" — matches any Gmail address (ends with @gmail.com); WHERE name LIKE "%son%" — matches "Johnson", "Bronson", "Jason" (contains "son" anywhere); WHERE code LIKE "A_3" — matches "A13", "AB3", "AX3" (A, then any one char, then 3). Case sensitivity: in MySQL, LIKE is case-insensitive for string columns with a case-insensitive collation (default utf8mb4_general_ci). Use LIKE BINARY for case-sensitive matching. Performance: LIKE with a leading wildcard ("%pattern") cannot use a B-tree index — it causes a full table scan. LIKE with a trailing wildcard only ("pattern%") CAN use an index. For full-text search, use MySQL FULLTEXT indexes and MATCH...AGAINST instead of LIKE.
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real MySQL / SQL project.