|
-
Dec 28th, 2004, 02:48 AM
#1
Thread Starter
Addicted Member
Like operator
Hi All,
I have a table which has several fields and one field is 'Keywords' which hold values to search records, for example, if one record has Keywords such as (Bank, Report, NBFI) and 2nd as (Bank, NBFI, Credit). I am using Access (Like operator) and ASP to fetch data on user typed keywords. So if user input 'Bank' as search keyword. It displays both records but if a user input (Bank, NBFI) it only fetches 2nd record. It doesn't show both records.
Can any one help me where am I wrong?
Thanks
-
Dec 29th, 2004, 07:27 AM
#2
Fanatic Member
Re: Like operator
When you perform your comparison, you are searching for Like "*Bank, NBFI*". You would need to be able to ammend your query to add a Like clause for each keyword:
VB Code:
Dim sSql
Dim arrKeyWord
Dim i
arrKeyWord = Split(sKeyWordString, ",")
sSql = "Select * From myTable Where "
For i = LBound(arrKeyWord) To UBound(arrKeyWord)
sSql = sSql & "keywordfield Like '*" & arrKeyWord(i) & "*' AND "
Next
'Remove the trailing AND
sSql = Left(sSql, Len(sSql) - 5)
Or something to that effect.
Chris
Master Of My Domain
Got A Question? Look Here First
-
Jan 1st, 2005, 12:42 AM
#3
Thread Starter
Addicted Member
Re: Like operator
Hi thanks for your solution. It works with a little bit of changes.
Thanks
 Originally Posted by vb_dba
When you perform your comparison, you are searching for Like "*Bank, NBFI*". You would need to be able to ammend your query to add a Like clause for each keyword:
VB Code:
Dim sSql
Dim arrKeyWord
Dim i
arrKeyWord = Split(sKeyWordString, ",")
sSql = "Select * From myTable Where "
For i = LBound(arrKeyWord) To UBound(arrKeyWord)
sSql = sSql & "keywordfield Like '*" & arrKeyWord(i) & "*' AND "
Next
'Remove the trailing AND
sSql = Left(sSql, Len(sSql) - 5)
Or something to that effect.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|