Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.