Using regular expressions in mysql

Using the keyword LIKE in a SELECT query is nice and easy but sometimes very limited. For more complex searches, use the keyword REGEXP.

It allows you to enter a Regular Expression search.

$query="SELECT * FROM `db`.`tbl` WHERE `NAME` REGEXP '^Ha+([a-zA-Z]*)'";

Will return ok for Hani, Hamed, Hazem, etc…

Post to Twitter Post to Delicious Post to Facebook

Comments are closed.

Seek in here
Translator
Archive

Twitter links powered by Tweet This v1.7.1, a WordPress plugin for Twitter.