Jump to content

Questions about executing a word search query.


onedumbcoder

Recommended Posts

is there a shorter way of doing this:

 

(title LIKE CONCAT('%', '$searchword', '%') OR description LIKE CONCAT('%','$searchword', '%'))

 

also when a user enters a search string, do i want to explode that string or not?

 

if yes

 

do i explode it by white spaces?

 

if yes

 

what if they enter 9 words, wouldnt that mean I have to do 9 like statments for the title and 9 like statements for the description?

 

Also

 

how would I make it so that the results with the most word matches in it

show up first?

 

for example lets say we search "Learning Mysql"

 

3 results come back,

 

first one only has matched learning

second one only has matched mysql

third one has matched both mysql and learning

 

how would I make it so that the third match comes up first then the rest, the only solution I thought of was a union where I do an AND in the first query and an OR in the second, but when we are talking about multiple words, we will have a very large number of possible combination. so i must be missing something

 

 

 

 

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.