Partial String Matching

Is there any alternative to LIKE '%...%' OR LIKE '%...%' in MySQL if you have to offer partial string matching on a large dataset?

re: Partial String Matching

MySQL allows you to do regular expressions using RLIKE. I don't know how the performance compares to using LIKE though. e.g.

SELECT * FROM my_table WHERE my_field LIKE '%foo%' or my_field LIKE '%bar%';

vs.

SELECT * FROM my_table WHERE my_field RLIKE '.*(foo|bar).*';

Here's the page in their doc:

http://dev.mysql.com/doc/refman/5.0/en/regexp.html

How would that possibly be

How would that possibly be faster? Also you might get queries like

field LIKE '%a%' AND (field LIKE '%b%' OR field LIKE '%c%')

I was looking for a product

I was looking for a product like Lucene but for partial string matching.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><div ?=?><p ?=?> <img ?=?><h1 ?=?><h2 ?=?><h3 ?=?>
  • Lines and paragraphs break automatically.
  • Glossary terms will be automatically marked with links to their descriptions
  • You may link to webpages through the weblinks registry

More information about formatting options

To combat spam, please enter the code in the image.