Jump to content

[SOLVED] How to search msql using "OR"


t_machine

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

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.