Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Boolean operator search on many fields

Thanks for the ideas on the last quetion. Simon and friends. I have not impletmented
them yet but have an idea where to start and where to start looking. I have
a new problem as well that I've been trying to take care of for a while now.

I am writting ASP code for a internet based search in a Library database.
I got the Boolean operator words NOT AND OR working on specific searchs like
on Author only or Title only. Where the comparison is Records containing
the <<Growing>> and NOT <<rockwool>> because both of these fields are in
the Title field and I can say "Select from table where Titlefield LIKE Growing
and Titlefield not LIKE rockwool". but in the general search I search in
7 fields. I though I had it working with a statement like this : "SELECT
AB,CO,AU,DP,ET,FT,TH,SO,PB,ORG FROM libinfo WHERE (CO LIKE '" & vcriteriat
& "' AND CO NOT LIKE '" & vcriteriaf & "') OR (AU LIKE '" & vcriteriat &
"' AND AU NOT LIKE '" & vcriteriaf & "') OR (ORG LIKE '" & vcriteriat & "'
AND ORG NOT LIKE '" & vcriteriaf & "') OR (FT LIKE '" & vcriteriat & "' AND
FT NOT LIKE '" & vcriteriaf & "') OR (ET LIKE '" & vcriteriat & "' AND ET
NOT LIKE '" & vcriteriaf & "') OR (DP LIKE '" & vcriteriat & "' AND DP NOT
LIKE '" & vcriteriaf & "') OR (AB LIKE '" & vcriteriat & "' AND AB NOT LIKE
'" & vcriteriaf & "') OR (DE LIKE '" & vcriteriat & "' AND DE NOT LIKE '"
& vcriteriaf & "') "

but what I figured out is that if I search for one author Not containing
another author it works or like my first example search for a word in a title
not containing another word in the title it works. But when I Search let's
say for Smith NOT rockwool (Author not word in title) then It still brings
the results. Which after looking closer at the string and the problem at
hand make sense. I then Typed a extremly long SQL statement that compared
to all the other fields as well and got an error stating that my string was
to complexe. I then tried simplifying it a bit by only comparing the most
important fields together and found out that still doesn't work with this
methode because it say OR between each comparison so it would always bring
back all the results even if it matched one of the criterias. I need help
using these boolean operators on a general search like this on. Everything
is possible but how complicated is this.
[2651 byte] By [Gweely] at [2007-11-9 21:09:58]
# 1 Re: Boolean operator search on many fields
Interface...
All those likes are likely to return some slow responses... With ASP why
not limit the SQL to include only what the person is searching on.

For example
IF your just searcing for a author that contains 'smith' title that does
not contain 'rockwool' why not limit your query to just deal with author
and title
so your select just gets authors like smith whose titles do not contain rockwool...
Why the rest?

The interface would allow the user of the system to select a variety of data
with interfaces such as
Drop down <Title; Author;Other> Drop Down<like, not like> <textbox> <drop
down> <and; or>
Drop down <Title; Author;Other> Drop Down<like, not like> <textbox> <drop
down> <and; or>
Drop down <Title; Author;Other> Drop Down<like, not like> <textbox> <drop
down> <and; or>
and then generate the SQL based on the selections made.

But Perhaps I don't fully understand your problem.

"Gweely" <gillestai@yahoo.com> wrote:
>
>Thanks for the ideas on the last quetion. Simon and friends. I have not
impletmented
>them yet but have an idea where to start and where to start looking. I have
>a new problem as well that I've been trying to take care of for a while
now.
>
>
>I am writting ASP code for a internet based search in a Library database.
>I got the Boolean operator words NOT AND OR working on specific searchs
like
>on Author only or Title only. Where the comparison is Records containing
>the <<Growing>> and NOT <<rockwool>> because both of these fields are in
>the Title field and I can say "Select from table where Titlefield LIKE Growing
>and Titlefield not LIKE rockwool". but in the general search I search in
>7 fields. I though I had it working with a statement like this : "SELECT
>AB,CO,AU,DP,ET,FT,TH,SO,PB,ORG FROM libinfo WHERE (CO LIKE '" & vcriteriat
>& "' AND CO NOT LIKE '" & vcriteriaf & "') OR (AU LIKE '" & vcriteriat &
>"' AND AU NOT LIKE '" & vcriteriaf & "') OR (ORG LIKE '" & vcriteriat &
"'
>AND ORG NOT LIKE '" & vcriteriaf & "') OR (FT LIKE '" & vcriteriat & "'
AND
>FT NOT LIKE '" & vcriteriaf & "') OR (ET LIKE '" & vcriteriat & "' AND ET
>NOT LIKE '" & vcriteriaf & "') OR (DP LIKE '" & vcriteriat & "' AND DP NOT
>LIKE '" & vcriteriaf & "') OR (AB LIKE '" & vcriteriat & "' AND AB NOT LIKE
>'" & vcriteriaf & "') OR (DE LIKE '" & vcriteriat & "' AND DE NOT LIKE '"
>& vcriteriaf & "') "
>
>but what I figured out is that if I search for one author Not containing
>another author it works or like my first example search for a word in a
title
>not containing another word in the title it works. But when I Search let's
>say for Smith NOT rockwool (Author not word in title) then It still brings
>the results. Which after looking closer at the string and the problem at
>hand make sense. I then Typed a extremly long SQL statement that compared
>to all the other fields as well and got an error stating that my string
was
>to complexe. I then tried simplifying it a bit by only comparing the most
>important fields together and found out that still doesn't work with this
>methode because it say OR between each comparison so it would always bring
>back all the results even if it matched one of the criterias. I need help
>using these boolean operators on a general search like this on. Everything
>is possible but how complicated is this.
Q*bert at 2007-11-11 23:53:01 >
# 2 Re: Boolean operator search on many fields
Thankx "Q*Bert" I'm not sure why I didn't think of that earlier. I was thinking
of giving the user full control but by building him a nice interface like
you said I can give him all the options possible and yet control all this
is sent to the server. This will actualy help prevent further problems that
might occure. Thanks again I will work on the interface first then move on
and thing should go a lot better. thanks

"Q*bert" <luke_davis_76@hotmail.com> wrote:
>
>Interface...
>All those likes are likely to return some slow responses... With ASP why
>not limit the SQL to include only what the person is searching on.
>
>For example
>IF your just searcing for a author that contains 'smith' title that does
>not contain 'rockwool' why not limit your query to just deal with author
>and title
>so your select just gets authors like smith whose titles do not contain
rockwool...
>Why the rest?
>
>The interface would allow the user of the system to select a variety of
data
>with interfaces such as
>Drop down <Title; Author;Other> Drop Down<like, not like> <textbox> <drop
>down> <and; or>
>Drop down <Title; Author;Other> Drop Down<like, not like> <textbox> <drop
>down> <and; or>
>Drop down <Title; Author;Other> Drop Down<like, not like> <textbox> <drop
>down> <and; or>
>and then generate the SQL based on the selections made.
>
>But Perhaps I don't fully understand your problem.
>
>"Gweely" <gillestai@yahoo.com> wrote:
>>
>>Thanks for the ideas on the last quetion. Simon and friends. I have not
>impletmented
>>them yet but have an idea where to start and where to start looking. I
have
>>a new problem as well that I've been trying to take care of for a while
>now.
>>
>>
>>I am writting ASP code for a internet based search in a Library database.
>>I got the Boolean operator words NOT AND OR working on specific searchs
>like
>>on Author only or Title only. Where the comparison is Records containing
>>the <<Growing>> and NOT <<rockwool>> because both of these fields are in
>>the Title field and I can say "Select from table where Titlefield LIKE
Growing
>>and Titlefield not LIKE rockwool". but in the general search I search in
>>7 fields. I though I had it working with a statement like this : "SELECT
>>AB,CO,AU,DP,ET,FT,TH,SO,PB,ORG FROM libinfo WHERE (CO LIKE '" & vcriteriat
>>& "' AND CO NOT LIKE '" & vcriteriaf & "') OR (AU LIKE '" & vcriteriat
&
>>"' AND AU NOT LIKE '" & vcriteriaf & "') OR (ORG LIKE '" & vcriteriat &
>"'
>>AND ORG NOT LIKE '" & vcriteriaf & "') OR (FT LIKE '" & vcriteriat & "'
>AND
>>FT NOT LIKE '" & vcriteriaf & "') OR (ET LIKE '" & vcriteriat & "' AND
ET
>>NOT LIKE '" & vcriteriaf & "') OR (DP LIKE '" & vcriteriat & "' AND DP
NOT
>>LIKE '" & vcriteriaf & "') OR (AB LIKE '" & vcriteriat & "' AND AB NOT
LIKE
>>'" & vcriteriaf & "') OR (DE LIKE '" & vcriteriat & "' AND DE NOT LIKE
'"
>>& vcriteriaf & "') "
>>
>>but what I figured out is that if I search for one author Not containing
>>another author it works or like my first example search for a word in a
>title
>>not containing another word in the title it works. But when I Search let's
>>say for Smith NOT rockwool (Author not word in title) then It still brings
>>the results. Which after looking closer at the string and the problem at
>>hand make sense. I then Typed a extremly long SQL statement that compared
>>to all the other fields as well and got an error stating that my string
>was
>>to complexe. I then tried simplifying it a bit by only comparing the most
>>important fields together and found out that still doesn't work with this
>>methode because it say OR between each comparison so it would always bring
>>back all the results even if it matched one of the criterias. I need help
>>using these boolean operators on a general search like this on. Everything
>>is possible but how complicated is this.
>
Gweely at 2007-11-11 23:54:04 >