I tried using "LIKE" but it is a bit too exact. Is there anyway to search for matched results using somewhat of a ballpark scope?
Asked
Active
Viewed 1,252 times
1
-
1Do you want 'fulltext' search - which breaks a string up at word boundaries and then can score on relavance? Or homophones (matching spelling errors)? Or both? Or something else? – HorusKol Feb 17 '11 at 02:27
-
I'm not very learned about MySQL but basically I need something that works similarly to "LIKE" but is just a wider scope. Hopefully I'm making sense. – nkcmr Feb 17 '11 at 02:32
-
1What do you mean "wider scope"? Is Fulltext too much? Do you want Regular Expression matching? – Jonah Feb 17 '11 at 02:39
-
@sightofnick: please give an example – Hoàng Long Feb 17 '11 at 02:40
-
Example: theres a file name it is: "files/example.mp3". If a search goes out for "examp" it should probably return that from the table. – nkcmr Feb 17 '11 at 02:46
-
can somebody give an example on how to use fulltext in a mysql query? – nkcmr Feb 17 '11 at 02:52
-
@sightofnick the simplest is `SELECT COUNT(*) FROM table WHERE MATCH (fieldname) AGAINST ('keyword');` but it may not be what you need judging from your previous comment. That's what you would usually use LIKE for. Why did that not work for you? You are aware of the `%` wildcard? `SELECT field FROM table WHERE field LIKE "%examp%"` – Pekka Feb 17 '11 at 02:56
1 Answers
4
You are probably looking for mySQL Fulltext search.
It features various searching modes - the "natural language" mode is probably closest to what you are looking for. Fulltext search can be tricky sometimes, be sure to read the comments in the manual for some non-obvious huge gotchas.
If that is not what you want, and you need to search for words that sound similar, check this question.