latox — 2010-03-18T08:47:44-04:00 — #1
Say I have the current query:
SELECT * FROM `table` WHERE `name` IN ('spy', 'next', 'door')
That searches to see if there is a field with the name spy, the name next, or the name door right?
I want to see if there is any names CONTAINING the words: spy, next and door.
For example: Private Spy - the word spy would come up with that.
For example: Next Home - the word next would come up with that.
For example: The Door Mat - the word door would come up with that.
If there is a result called Spy Next Door, it only comes up with 1 result.
Help please? Is it possible what I'm asking? :x
r937 — 2010-03-18T08:59:23-04:00 — #2
WHERE name LIKE '%spy%'
OR name LIKE '%next%'
OR name LIKE '%door%'
alandy — 2010-03-18T09:01:48-04:00 — #3
Don't understand your mean?
latox — 2010-03-18T09:11:33-04:00 — #4
I know LIKE works for that, but my script won't work like that, isn't there another way?
didusayscript — 2010-03-18T09:19:06-04:00 — #5
The 'where clause' by r937 does exatly what you asked for, unless I am missing something.
latox — 2010-03-18T09:23:01-04:00 — #6
I was aiming to use IN and just use what I had coded as posted recently on the topic above.
But now it searches for the exact word entered, not a LIKE %$str% query like I am looking for, so I'm going to have to redo it.
r937 — 2010-03-18T09:35:27-04:00 — #7
yes, get a new script
didusayscript — 2010-03-18T09:58:45-04:00 — #8
With your sample on the other thread if you use $str - you can do the following
$whereclause = "where name LIKE '%".implode("%' OR name LIKE '%",str_word_count($str,1,'1234567890'))."%'";