Jump to content

MySQL "contains" search?


meman1188

Recommended Posts

I'm trying to pull certain phrases out of search queries that users enter. For example, if the search query is "Bill Gates turns 52", I would like to catch "Bill Gates" which is an entry in the MySql table `topics` under the column `topic`. So how do I preform this type of search on the table.. something like "Search Query" CONTAINS (`topic`).

 

It is not a wildcard search (%Search Query%) because the query is bigger than the value in the DB and full text does not work because I want exact matches to the topic name in the database.

 

Thanks for the help

Link to comment
Share on other sites

The problem with full text is it will return partial matches.  For example, "Bill must cross the gates" is not the same as "bill gates", but will be returned in a full text search, not to mention partial results like "bill throws the ball" would cause results also.

 

I can't put the whole search query in quotes, cause i don't want to match the whole thing, just part of it, and I can't think of any way to determine which part should be in quotes, programmatically.  And to solve the partial problem, i could put "+" on the terms, but i don't want all the words to be present, just the one that make up the topic name.

Link to comment
Share on other sites

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.