Jump to content

Accurate Search


Beasts

Recommended Posts

hey,

i'm working on an online dictionary for my native language. i noticed when searching, the results are sometimes inaccurate.

this is my query.

 

SELECT * FROM words WHERE word LIKE '%$q%'"

 

for example, if i search for "tive" (supposing this is a real word) it doesnt return the word tive and will return "native" because it occurs first in the database. so i suppose basically i'm looking for a way to sort them by relevancy?

Link to comment
https://forums.phpfreaks.com/topic/213855-accurate-search/
Share on other sites

if you are trying to search looking for exact match you should not be using LIKE

 

.... i noticed when searching, the results are sometimes inaccurate.

this is my query.

 

SELECT * FROM words WHERE word LIKE '%$q%'"

 

your results are not inaccurate... they are exactly what are you asking for using the LIKE clause with the % pattern at the beginning/end...

Link to comment
https://forums.phpfreaks.com/topic/213855-accurate-search/#findComment-1113041
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.