close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

search and existing sql WHERE clause

Thread began 2/18/2011 7:29 am by mark336119 | Last modified 2/18/2011 11:46 am by Jason Byrnes | 2670 views | 11 replies |

mark336119

search and existing sql WHERE clause

I have a search setup and working. I was hoping to limit the results simply by using a WHERE in the database sql.

ie. SELECT * FROM content WHERE pagecategory = ?

However, existing WHERE clauses in the sql are ignored by DA search (cannot exclude anything from the search pool).

Is there something I need to be aware of here, or I am missing?

Sign in to reply to this post

Jason ByrnesWebAssist

Add it as a criteria to the data assist search behavior so it will be included in the where clause that data assist search creates.

Sign in to reply to this post

mark336119

Had tried that, but couldn't get that to return properly either:

WADbSearch3_whereClause=BuildFilterString("pagecategory","do_not_show_on_menu","AND NOT","Includes",0,WADbSearch3_wildCard,WADbSearch3_dateSeparator,WADbSearch3_whereClause)

Sign in to reply to this post

Jason ByrnesWebAssist

it looks like the criteria you are using is AND NOT Includes do_not_show_on_menu


from the SQL example, it looks you should be using
AND Equals do_not_show_on_menu

Sign in to reply to this post

mark336119

sorry, the original sql was an exclude (SELECT * FROM content WHERE pagecategory <> ?). I was just trying a few options to see if I could include/exclude anything at all.

problem is, none of the filters in the DA criteria seem to factor (excluding or including). My limits were simple... so was just going to do that in the sql, but that is ignored as well.

Sign in to reply to this post

Jason ByrnesWebAssist

the <> operator is NOT EQUALS, send a copy of your page so i can see the entire code to offer debugging advice.

Sign in to reply to this post

mark336119

again, trying to exclude certain pages from showing in the search results.

searching works fine, but cannot exclude anything. Tried in the sql statement, and with DA filters. thanks.


<%' PAGES SEARCH *********************************************%>

<%
dim WADbSearch3_DefaultWhere
WADbSearch3_DefaultWhere = ""
if (cStr(Request.Form("WADbSearch1")) <> "") then
dim WADbSearch3_whereClause, WADbSearch3_dateSeparator, WADbSearch3_wildCard
WADbSearch3_wildCard = "%"
WADbSearch3_dateSeparator = "'"


if ("ACCESS" = "ACCESS") then
WADbSearch3_dateSeparator="#"
end if
if ("ACCESS" = "ORACLE") then
WADbSearch3_dateSeparator="TO_DATE('"
end if
if ("ACCESS" = "MYSQL") then
WADbSearch3_dateSeparator="MYSQL"""
end if

'keyword array declarations
Dim WADbSearch3_KeyArr0, WADbSearch3_KeyArr1, WADbSearch3_KeyArr2, WADbSearch3_KeyArr3
WADbSearch3_KeyArr0 = Array("pagecategory")
WADbSearch3_KeyArr1 = Array("pagesection")
WADbSearch3_KeyArr2 = Array("cont_cnt")
WADbSearch3_KeyArr3 = Array("subsection")


' added by mark, remove spaces which disable searchability
Dim searchphrase_pages
searchphrase_pages = RTRIM(cStr(Request.Form("search")))

'comparison list additions
WADbSearch3_whereClause=BuildKeyword(WADbSearch3_KeyArr0,"" & searchphrase_pages & "","OR","Includes",",%20","%20","%22","%22",0,WADbSearch3_wildCard,WADbSearch3_dateSeparator,WADbSearch3_whereClause)
WADbSearch3_whereClause=BuildKeyword(WADbSearch3_KeyArr1,"" & searchphrase_pages & "","OR","Includes",",%20","%20","%22","%22",0,WADbSearch3_wildCard,WADbSearch3_dateSeparator,WADbSearch3_whereClause)
WADbSearch3_whereClause=BuildKeyword(WADbSearch3_KeyArr2,"" & searchphrase_pages & "","OR","Includes",",%20","%20","%22","%22",0,WADbSearch3_wildCard,WADbSearch3_dateSeparator,WADbSearch3_whereClause)
WADbSearch3_whereClause=BuildKeyword(WADbSearch3_KeyArr3,"" & searchphrase_pages & "","OR","Includes",",%20","%20","%22","%22",0,WADbSearch3_wildCard,WADbSearch3_dateSeparator,WADbSearch3_whereClause)

WADbSearch3_whereClause=BuildFilterString("pagecategory","do_not_show_on_menu","AND NOT","Includes",0,WADbSearch3_wildCard,WADbSearch3_dateSeparator,WADbSearch3_whereClause)
'WADbSearch3_whereClause=BuildFilterString("siteside","" & cStr( Session("siteside") ) & "","AND","Includes",0,WADbSearch3_wildCard,WADbSearch3_dateSeparator,WADbSearch3_whereClause)

if (1 = 1) then
Session("WADbSearch3_search")=WADbSearch3_whereClause
end if
else
if (1 = 1) then
if (cStr(Session("WADbSearch3_search")) <> "") then
WADbSearch3_whereClause = cStr(Session("WADbSearch3_search"))
else
WADbSearch3_whereClause = WADbSearch3_DefaultWhere
end if
else
WADbSearch3_whereClause = WADbSearch3_DefaultWhere
end if
end if
%>

<%
Dim searchresults_pages__MMColParam
searchresults_pages__MMColParam = "do_not_show_on_menu"
If (Request("MM_EmptyValue") <> "") Then
searchresults_pages__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim searchresults_pages
Dim searchresults_pages_cmd
Dim searchresults_pages_numRows

Set searchresults_pages_cmd = Server.CreateObject ("ADODB.Command")
searchresults_pages_cmd.ActiveConnection = MM_khtml_STRING
searchresults_pages_cmd.CommandText = "SELECT * FROM content_cnt WHERE pagecategory <> ?"
searchresults_pages_cmd.Prepared = true
searchresults_pages_cmd.Parameters.Append searchresults_pages_cmd.CreateParameter("param1", 200, 1, 50, searchresults_pages__MMColParam) ' adVarChar

setQueryBuilderSource searchresults_pages_cmd, WADbSearch3_whereClause, false
Set searchresults_pages = searchresults_pages_cmd.Execute
searchresults_pages_numRows = 0
%>
<% ' END PAGES Search *****************************%>

Sign in to reply to this post

Jason ByrnesWebAssist

to see the sql that is being generated, add the following code after the <body> tag:


SQL: <%=searchresults_pages_cmd.CommandText %>


post the results back please.

Sign in to reply to this post

mark336119

here it is...

SELECT * FROM content_cnt WHERE pagecategory <> ? AND ((pagecategory LIKE '%contact%')) OR ((pagesection LIKE '%contact%')) OR ((cont_cnt LIKE '%contact%')) OR ((subsection LIKE '%contact%')) AND NOT (pagecategory LIKE '%do_not_show_on_menu%')

Sign in to reply to this post

Jason ByrnesWebAssist

well, it is adding both of the conditions to the where clause, your initial where clause is not being ignored, it is being added in.



this section:
WHERE pagecategory <> ?


is initial where clause, and this one:
AND NOT (pagecategory LIKE '%do_not_show_on_menu%')


is the new criteria that you added. Is "do_not_show_on_menu" the actual value that is stored in that column?

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...