LIKE Query matching
I am using the following SQL query:
LIKE '%"$_POST[var]"%'
When users do a search with flat screen
it doesn't return results with 'flat' OR 'screen' ONLY the exact match.开发者_JAVA技巧
What is the best approach?
The approach you are using will probably work, but it will be slow.
For text searches it might be better to use a full text index. There is support for this built into most databases and you could also look at an external indexing engine such as Sphinx or Lucene.
You probably need Full-Text Search.
Note: That link is for MySQL, but other databases have Full-Text too.
You could also use a regular expression, eg
where column~'flat\s+screen'
精彩评论