We provided a peek at ANSI SQL pattern matching earlier with the query:
SELECT name FROM people WHERE name LIKE 'Stac%'
operator, we compared a column
name) to an incomplete literal
'Stac%'). MySQL supports the ability to place
special characters into string literals that match like wild cards.
character, for example, matches any
arbitrary number of characters, including no character at all. The
SELECT statement would therefore match
Stacy, and even
matches any single character.
Stac_y would match only
Stac__ would match
Stacey, but not
Pattern-matching expressions should never be used with the basic
comparison operators. Instead, they require the
operators. It is also important to
remember that these comparisons are case-insensitive except on binary
MySQL supports a non-ANSI kind of pattern matching that is actually
much more powerful using the same kind of expressions to which Perl
programmers and grep users are accustomed. MySQL
refers to these as extended regular expressions.
these operators must be used with the
operators. MySQL provides synonyms for these:
RLIKE. Table 3-7 contains a
list of the supported extended regular expression patterns.
Table 3-7. MySQL extended regular expressions
Matches any single character. ...