![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Let's say that someone is searching for, say, "billybobs" or "billybobsslop", and the field contains "Billy Bob's Homemade Slop House & Bar" (spaces, non-alphanumeric characters, etc). How can I write the query so that, if there's not an exact result, then return the most likely? Here's what I'm currently using: SELECT SQL_CACHE DISTINCT id, MATCH(name) AGAINST ('billybobsslop' IN BOOLEAN MODE) AS occurrences FROM restaurants WHERE MATCH(name) AGAINST ('billybobsslop' IN BOOLEAN MODE) TIA, Jason |
#3
| |||
| |||
|
|
I had originally just changed any space or non-alphanumeric character to a -, then de-duped the - (so I wouldn't have 2 - in a row), then instead of MATCH AGAINST I had replaced the - with %, and used LIKE. Which works great if the address given is something like: http://www.example.com/billy-bobs-slophouse/ Given *BY WHOM*? *The person conducting the search? *The person who wants his info entered into your database so people can find him? * |
#4
| |||
| |||
|
|
case, Billy Bob himself would have given his customer the website address, probably on his menu or a business card. But, assuming that it's on his menu, then people aren't going to remember an exact URL when they get home, which is why I'm hoping to make it a bit more intuitive. |
|
This, of course, also means that he can't very well be expected to give out an address like: http://www.example.com/billy%20bob%27s%20slophouse/ |
|
I had considered another column that was loaded up with potential search phrases, but I realize that it could become a bit large, have a lot of room for programming error, and worse, run the risk of duplicating another listing. That's why I was hoping there was a query modification to just find the most likely result. |
![]() |
| Thread Tools | |
| Display Modes | |
| |