MySQL LIKE
In MySQL, the LIKE condition filters the results obtained through the SELECT, INSERT, UPDATE, and DELETE statements based on pattern matching.
Syntax:
WHERE expressions LIKE pattern [ ESCAPE 'escape_character' ]
Parameters:
expressions: It is used to specify a column or a field.
pattern: It is used to specify the character expression for pattern matching.
escape_character: It is an optional parameter that is used to test for literal instances of a wildcard character such as
Example: Using wildcard: Percent
Query: Output: Example: Using wildcard: Underscore(_). Items table: Query: Output: Example: Using NOT. Items table: Query: Output:
ID
NAME
QUANTITY
1
Electronics
30
2
Sports
45
3
Fashion
100
4
Grocery
90
5
Toys
50
SELECT name
FROM items
WHERE name LIKE 'Ele
NAME
Electronics
ID
NAME
QUANTITY
1
Electronics
30
2
Sports
45
3
Fashion
100
4
Grocery
90
5
Toys
50
SELECT name
FROM items
WHERE name LIKE 'Elec__onics';
NAME
Electronics
ID
NAME
QUANTITY
1
Electronics
30
2
Sports
45
3
Fashion
100
4
Grocery
90
5
Toys
50
SELECT name
FROM items
WHERE name NOT LIKE 'Ele
NAME
Electronics