MariaDB LIKE Clause
In MariaDB, LIKE clause is used with SELECT statement to retrieve data when an operation needs an exact match. It can be used with SELECT, INSERT, UPDATE and DELETE statement.
It is used for pattern matching and return a true or false. The patterns used for comparison accept the following wildcard characters:
"%" wildcard character: It matches numbers of characters (0 or more).
"_" wildcard charcter: It matches a single character. It matches characters within its set.
Using % wildcard (percent sign wildcard)
We have a table "Employees", having the following data.
Let's use % wildcard with LIKE condition to find all of the names who begins with "L".
You can also use the % wildcard multiple times within the same string.
It will return all names which contains "L" within.
Using _ wildcard (underscore wildcard)
Let's use _ wildcard with LIKE condition. The underscore wildcard checks only one character. Let's fetch name of the employee which is like "Ra_ul".
LIKE Clause with NOT operator
In MariaDB, you can use NOT operator with LIKE clause. Let's use the % wilcard with the NOT Operator. Here we find out employees whose name does not start with 'A'.