what is mysql like?

The LIKE operator is used in a WHERE clause to search for a specific pattern in a column.
There are two wildcards used with the LIKE operator:
The percent sign (%) represents zero, one, or multiple characters
The underscore sign (_) represents one, single character
You can combine any number of conditions using AND or OR operators.

Example :-

SELECT * FROM ittutorial WHERE tutorial LIKE '%php%';

WHERE CustomerName LIKE 'a%' Finds any values that start with "a"
WHERE CustomerName LIKE '%a' Finds any values that end with "a"
WHERE CustomerName LIKE '%or%' Finds any values that have "or" in any position
WHERE CustomerName LIKE '_r%' Finds any values that have "r" in the second position
WHERE CustomerName LIKE 'a_%' Finds any values that start with "a" and are at least 2 characters in length
WHERE CustomerName LIKE 'a__%' Finds any values that start with "a" and are at least 3 characters in length
WHERE ContactName LIKE 'a%o' Finds any values that start with "a" and ends with "o"

SELECT * FROM ittutorial WHERE tutorial LIKE 'p%'; SELECT * FROM ittutorial WHERE tutorial LIKE '%java';

Like

The LIKE Operator used with the WHERE clause to search for a specific pattern in a string. The string pattern contains wildcard characters that represent missing characters.

SELECT * FROM ittutorial WHERE name course '%P';
// Here the percentage sign is a wildcard character.

Fetch all the employees whose name ends with ab.

This means return all records whose name ends with the string ‘ab’.

SELECT * FROM ittutorial WHERE tutorial name '%ab';

Fetch all employee whose name contains the word 'ma'

the following like statement return all the users from the users table where the Name containing the word ‘ma’ anywhere in the name column

SELECT * FROM Users WHERE Name LIKE ‘%ma%’;

NOT LIKE Operator

Fetch all the users whose name does not start with m.

SELECT * FROM users WHERE Name NOT LIKE ‘m%’;

Fetch all users whose name does not contain the word sa

SELECT * FROM users WHERE Name NOT LIKE ‘%sa%’;





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here


Ittutorial