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

 

 

 

 

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.