What is the LIKE operator in SQL?
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.