Ajax AutoComplete Support Product Page
This topic was archived
Please can you help me with manual SQL changes?
Asked 25 Jun 2009 00:25:13
1
has this question
25 Jun 2009 00:25:13 Jason Burns posted:
Hi,I'm trying desparately to get the following search on my database column. Eg.
'green blue orange'
if a user types in 'green blue' there is a match in the dropdown menu
if a user types in 'blue orange' there is a match in the dropdown menu
if a user types in 'green orange' there is a NO match in the dropdown menu
I have tried to manipulate the VbScript in the autocomplete-ajax-asp-1.asp page without joy. If the column to be searched were chapters from a book, and a user typed in 'sky' and 'beach' then there should be an option to match these words ANYWHERE in a chapter.
Meanwhile, can you help with this PLEASE!!
Cheers,
Jason
normal code... then
Dim aString, SearchString, SearchResult
SearchResult = ""
SearchString = ""
aString = ""
aString=Split(sString," "

for i = 0 to Ubound(aString)
if i > 0 then
SearchString = SearchString & " AND " & sPrimary & " LIKE '%" & aString(i) & "%'"
else
SearchString = " WHERE " & sPrimary & " LIKE '%" & aString(i) & "%'"
end if
next
if (SearchString <> ""

Sql = "SELECT DISTINCT TOP 25 " & sPrimary & " FROM " & sTable & Replace(SearchResult, "'", "'"

... then your code
Set rsXml_cmd = Server.CreateObject ("ADODB.Command"

rsXml_cmd.ActiveConnection = MM_connAcestock_STRING
rsXml_cmd.CommandText = Sql
rsXml_cmd.Prepared = true
etc