Databases Reference
In-Depth Information
SQL's
LIKE
operator. This operator accepts wildcard characters: the
%
character
(which matches any number of characters) and the underscore (
_
) character (which
matches a single character). Thus we can use
%cinema%
to let phpMyAdmin
find any substring that matches the word
'cinema'
. If we left out both wildcard
characters, we will get exact matches with only that single word.
Since phpMyAdmin 2.6.0, this substring matching has been made easier to access,
by adding it to the
Operator
drop-down list. We only have to enter the word
cinema
and use the operator
LIKE %...%
to perform that match. We should avoid using this
form of the
LIKE
operator on big tables (thousands of rows), since MySQL does not
use an index for data retrieval in this case, leading to wait time that could add up
to half an hour (or more). This is why this operator is not the default one in the
drop-down list, even though this method of searching is commonly used on
smaller tables.
In versions prior to phpMyAdmin 2.6.0, we need to manually insert the
%
characters to obtain '
%cinema%'
, and use the
LIKE
operator from the
drop-down list.
We also specify that the results be sorted (in ascending order) by title. In the
search interface, only one sorting field is possible. Here is a screenshot showing
how we ask for a search on
cinema
with the operator
LIKE %...%
:
The
LIKE
operator can be used for other types of wildcard
searching, for example
History%—
which would search for this
word at the beginning of a title. This form of the
LIKE
query
also has the benefit of using an index, if MySQL finds one that
speeds up data retrieval.
Search WWH ::
Custom Search