Database Reference
In-Depth Information
Note
To Learn More Full coverage of regular expressions is beyond the scope of this
chapter. While the basics are covered here, for a more thorough introduction to regu-
lar expressions you might want to obtain a copy of my Sams Teach Yourself Regular
Expressions in 10 Minutes (ISBN 0672325667).
Using Regular Expressions
So what does this have to do with MariaDB? As already explained, all regular
expressions do is match text, comparing a pattern (the regular expression) with
a string of text. MariaDB provides rudimentary support for regular expressions
with WHERE clauses, allowing you to specify regular expressions that are used to
filter data retrieved using SELECT .
Note
Just a Subset of the Regular Expression Language If you are already familiar with reg-
ular expressions, take note. MariaDB supports only a small subset of what is supported
in most regular expression implementations, and this chapter covers most of what is
supported.
This will all become much clearer with some examples.
Basic Character Matching
We start with a simple example. The following statement retrieves all rows
where column prod_name contains the text 1000 :
Input
SELECT prod_name
FROM products
WHERE prod_name REGEXP '1000'
ORDER BY prod_name;
Output
+--------------+
| prod_name |
+--------------+
| JetPack 1000 |
+--------------+
 
 
 
Search WWH ::




Custom Search