Mysql Pattern Matching

How to Use Pattern Matching in select Statement?


MySQL Pattern Matching :

Sometimes we may need to look for the table with a certain matching character. In MySQL we use LIKE or NOT LIKE operator for comparison. In MySQL the patterns are case-insensitive by default.

Example :

Let us consider an example of pattern matching query to display the student names starting with the letter M.
Mysql Pattern Matching
In the above example query, it will list all the names that starts with the letter M from the table student.
The following example query will list the names that ends with letter e.
Mysql Pattern Matching
The above and following examples shows how to use the mysql pattern matching and the types of pettern matchings. We can also list the names that contains a specific letter anywhere. The following example query will list the names that contains "a".
Mysql Pattern Matching
Suppose if we want to find the names that contain exactly five characters, we use a special character "_"(underscore). The following query will list all the five letter names from the table student.
Mysql Pattern Matching

Ask Questions

Ask Question