Wildcard Character(_)
A character in a string is represented by the wildcard character _. It helps when you want to match a character in a specific location. The below examples will give you an idea of how to use _ wildcard character.
Query 1:
SELECT last_name FROM employees WHERE last_name LIKE 'Jo_hn';
This example would return all the employees whose last name is 6 characters long, where the first character is J and last two characters is hn.
Output:
Query 2:
SELECT * FROM employees WHERE department_id LIKE '1%' COLLATE utf8mb4_general_ci;
This query will retrieve employees with department_id starting with 1 .
Output:
LIKE Clause in MariaDB
The LIKE clause is a powerful tool in database querying that allows users to perform flexible and dynamic searches based on pattern matching. In MariaDB, the LIKE clause is a valuable asset for searching and retrieving data from tables. The features, syntax, and effective uses of the LIKE clause in MariaDB will all be covered in this article.