Question №14
Remaining:
How to use the LIKE operator and what is it used for?
Sample Answer
Show Answer by Default
The LIKE operator is used in WHERE clauses to search for rows that match a specific pattern. Wildcards are used in the patterns:
- % — matches any sequence of characters (including an empty sequence).
- _ — matches any single character.
Examples of usage:
- Searching for rows that start with “A”:
MySQL 8.1SELECT * FROM employees WHERE name LIKE 'А%';
- Searching for rows that end with “e”:
MySQL 8.1SELECT * FROM employees WHERE name LIKE '%e';
- Searching for rows where the second character is “a”:
MySQL 8.1SELECT * FROM employees WHERE name LIKE '_а%';