Forum Moderators: open

Message Too Old, No Replies

How to find similar matches when searching?

I need to pull similar matches from a search query.

         

benj0323

7:28 am on Aug 12, 2006 (gmt 0)

10+ Year Member



I am using MySQL 5.0.

Anyways, I have a table named "words" with one column called "word". This contains a bunch of random words / strings. It could contain "cat" or it could contain "tuengop" which is not a word.

If someone searches for the word "bat" and "bat" is not in my database I would like to list out the closest word. So if "cat" was in my database I would like to say "did you mean cat?". That sort of thing.

I hope I wasn't confusing.

Any help is greatly appreciated, I don't know where to start really.

Thanks.

scintex

11:57 am on Aug 14, 2006 (gmt 0)

10+ Year Member



Hi,

Try googling for RLIKE and SOUNDEX. They should get you going on the right path.

Advantages & disadvantages for both, so do some research first.

Keep in mind that you could either do this in the database, or potentially do the logic within the code (e.g. PHP).

S