Reprence Html CSS javascript PHP MySQL Bootsrap

MySQL Wildcard Characters

A wildcard character is used to substitute one or more characters in a string.

Wildcard characters are used with the LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

Wildcard Characters in MySQL

60

The wildcards can also be used in combinations!

Here are some examples showing different LIKE operators with '%' and '_' wildcards:

61

Demo Database

The table below shows the complete "Customers" table from the Northwind sample database:

62 63 64

Using the % Wildcard

The following SQL statement selects all customers with a City starting with "ber":


The following SQL statement selects all customers with a City containing the pattern "es":



Using the _ Wildcard

The following SQL statement selects all customers with a City starting with any character, followed by "ondon":


The following SQL statement selects all customers with a City starting with "L", followed by any character, followed by "n", followed by any character, followed by "on":