Telephone Directory Search

4

I have a search problem with phrases, I have a search field and I am using the LIKE operator to do this, but it is not serving me correctly, I have tried to use SOUNDEX now, but it only returns one word with the same phonetic than the other word, what I need is to find a word between a phrase. Here is my SQL code.

  $sql = "SELECT * FROM tabela WHERE LOWER('') LIKE LOWER('%$valor%')";
    
asked by anonymous 09.01.2015 / 17:53

1 answer

2

As I understand you do not really want a phonetic search, you just want an alternative to LIKE (which is not performative, especially when searching for a word in the middle of the text).

This alternative would be the ability to Full Text Search

To create an index in the columns:

ALTER TABLE tabela ADD FULLTEXT(meu_campo);

For search:

SELECT * FROM tabela 
WHERE MATCH (meu_campo)
AGAINST ('valor' IN NATURAL LANGUAGE MODE);
    
09.01.2015 / 17:59