Jump to content

mysql "LIKE" and php search


snizkorod

Recommended Posts

Hello, Hopefully I can get an answer here :D

 

I am interested in making a search based on keywords. I am searching through a column that is TEXT; the entries are all long passages... I am interested in returning rows that contain the keywords that i'm looking for. Also, i'm extracting the stems from the keywords with the 2005 Richard Heyes (http://www.phpguru.org/) PorterStemmer algorithm.

 

First, I need to know if using

 

"field LIKE '%$keyword%'"

 

search algorithm will suffice. I'm not sure if mysql will look for %$keyword% as a sub string of the text or merely treat $keyword as an absolute string?

 

Example: query for

"field LIKE '%walking%'"

returns nothing from this mysql table:

ID

TEXT

1

"I am walking around"

2

"after a while i fall down and can't get up... Help me!

 

So far, i have noticed that my query doesn't look for the appropriate parts...

 

I unfortunately cannot use FULLTEXT as i'm running an InnoDB engine on this table.

 

Any suggestions?

Link to comment
https://forums.phpfreaks.com/topic/207995-mysql-like-and-php-search/
Share on other sites

Since the following query does match your id 1 row (just tested), you must be doing something else wrong in your actual code or query -

SELECT * FROM your_table where field LIKE '%walking%'

 

It would take seeing some actual information about what you are doing to be able to help you.

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.