Jump to content

Recommended Posts

I am wondering if anyone can help with this. I already know the basics of searching mysql but if the user has a space, it does not treat the search as "OR".

 

Example:

 

Seach phrase => "cool car"

 

Notice the space? For some reason my results are only if the exact phrase cool car exists but not cool bike or red car.

How can I have it search mysql and return any matches even if the phrase does not exists?

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/83053-solved-how-to-search-msql-using-or/
Share on other sites

explode the phrase into an array, then iterate through the array of search words creating a seperate query for each word

 

or, if it's possible use the OR keyword inbetween every word in the array, something like:

SELECT * FROM table

WHERE name

LIKE word1

OR word2

OR word3

OR word4;

 

I'm not sure if this is possible, though, you'll have to test it out

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.