MySQL - Cool Trix - REGEXP
MySQL REGEXP
using like in mysql works great for querying records that starts with, ends with or contains some data. But what if you want to find several records that could start with ABC or start with BCD. MySql has a neat little function in the where clause that allows you to provide a regular expression to filter your query result.
select * from widgets where name REGEXP 'foo|bar'
This query will return all the widgets that contain foo or bar.
Much better than
select * from widgets where name like '%foo%' or name like '%bar%'