|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Search for multiple words within one field
I have a test database with filenames, images and keywords etc. The keyword field contains several keywords, like Cruiseskip vestlandet Cruisebåt Cruiseskip Cruiseskip Flåm Cruiseskip vestlandet Skip Båt. When searching for two words that follow eachother I get a result but when searching for two or more words within the keyword field that do not follow directly after eachother I get no result.
I also need to be able to get a result from multiple keywordfields, like one image has Cruiseship as a keyword, another image has River as a keyword, if I search for both these words I get no result and I want to retreive both images. My SQL looks like this. rsImages_cmd.CommandText = "SELECT Name, Keywords FROM Kalimages WHERE Keywords LIKE'%" & strSearch & "%'" & "OR Name LIKE'%" & strSearch & "%'" The code for the entire page Link to live page Any help would be appreciated. |
|
#2
|
||||
|
||||
|
you want to search "for two or more words within the keyword field"
you need something like this -- Code:
WHERE Keywords LIKE '%word1%' AND Keywords LIKE '%word2%' |
|
#3
|
|||
|
|||
|
Quote:
I tried using AND but this returned no results. |
|
#4
|
||||
|
||||
|
Quote:
![]() |
|
#5
|
|||
|
|||
|
Quote:
I tried removing the last part of the SQL statement, the SQL would the look like this - "SELECT Keywords FROM Kalimages WHERE Keywords LIKE'%" & strSearch & "%'" - but it made no difference. Searching for two or more words that do not directly follow eachother in the keyword field gave no result. |
|
#6
|
||||
|
||||
|
do me a favour, please test the query outside of php first
just to restore your confidence in SQL ![]() |
|
#7
|
|||
|
|||
|
Quote:
I've found no fault in the SQL statement, but I think I need to do some sort of split function when using multiple keywords. It's been a while since i've done this, but I'll do some testing. |
|
#8
|
||||
|
||||
|
since there is no fault in the SQL, i'll move this thread to the php forum
|
|
#9
|
||||
|
||||
|
He's using VB Script (ugh) so we should probably move the thread again.
-Dan
__________________
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002 Think we're being rude? Please read this. Trying to argue intelligently? Please read this. |
|
#10
|
|||
|
|||
|
Quote:
I am using ASP and VBScript. Feel free to move the thread to where it correctly belongs. Sorry for posting in the wrong forum. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > Search for multiple words within one field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|