Mysql regexp or rlike function it same as PHP preg_match() function.
It save the time write code and filter the data.
Example:
REGEXP
SELECT * FROM table WHERE name REGEXP '^m';RLIKE
SELECT * FROM table WHERE name RLIKE '^m';
Example Data
Id | Name | Date |
1 | myteststring | 2013-01-1 |
2 | myteststring2 | 2013-01-5 |
3 | teststring | 2013-01-4 |
4 | examplestring | 2013-01-8 |
5 | examplestring | 2013-01-7 |
Query:
SELECT * FROM table WHERE name REGEXP '^m'; or SELECT * FROM table WHERE name RLIKE '^m';Output:
Id Name Date -------------------------------- 1 myteststring 2013-01-1 2 myteststring2 2013-01-5