How to use mysql LIKE to create a search system?
How t开发者_Go百科o use mysql LIKE to create a search system?
Don't. It will be hard to avoid false positives, and it will run hundreds or thousands of times slower than using a real fulltext search solution.
Suppose you search for the word "one":
SELECT * FROM SomeTable WHERE textfield LIKE '%one%';
This will also match text where words such as "money" "lonely" "bone" etc.
And it has to scan the whole table to compare the pattern to the text in every row. There's no way a conventional index can help.
Instead, use a FULLTEXT index, or a search engine like Solr or Sphinx Search, or external search engine like Google Custom Search Engine or Yahoo Search Web Services.
See also my presentation Practical Fulltext Search in MySQL.
SELECT * FROM mytable WHERE SEARCHABLE_FIELD LIKE "%SOMETHING%"
It's not really a good way to create a search system, but that's what you are asking... so there you go.
select * from where like ''
Something like that ...
you can use % as a wildcard...
精彩评论