I assume you have a big form where the user fills in some fields and leaves
others empty. Then you want the query to include a lot of tests separated
by AND's (not sure why you're saying "OR" - perhaps you're talking about the
ASP that puts it together).
I'd do it in two steps:
Firstly, buzz through the form concocting test clauses (complete with their
surrounding parentheses) and put them into consecutive spots in a temporary
array. In JScript, it'd be:
var clauses = new Array;
then
clauses[clauses.length] = <a clause>
clauses[clauses.length] = <a nuther clause>
Where a tolerance is needed (e.g. on age) you'd deal with it at this time,
so the clause going into the array looks like:
"((age >= 27) and (age <= 33))"
for a +/- 3 year tolerance.
Once you've finished with the form, you've got an array full of clauses.
Now al you've got to do is construct the SQL. Buzz through the array and
create the string. Indeed, in JScript you could do it in one step:
SQL = ..... + clauses.join (" and ") + ...
Don't know about the equivalent statements in VBScript, but I assume
extensible arrays and join facilities exist.
You can also check the length of the clauses array to make sure that the
enquiry includes at least something to check on - indeed, you'd probably
insist on at least a length of 3 to make sure you had some shot at reducing
the size of the record set.
You can do the same thing with string concatenation, of course, but this one
seems to cry out for an array.
HTH
Dave S
----- Original Message -----
From: "Dian Chapman" <[EMAIL PROTECTED]>
To: "Group - ASP" <[EMAIL PROTECTED]>
Sent: Thursday, August 26, 2004 12:22 PM
Subject: [ASP] Multi Criteria Searches
> Hi folks...
>
> I've volunteered to help a Missing Persons site get their stuff back
online
> (after their previous dev demanded money and then bailed<sigh>).
>
> Most shouldn't be too difficult...just a lot of grunt work. However, there
> will be one complex search pages for which I'm not quite sure how to
> handle. This being for an actual missing or found person match...for which
> there can be a pile of items that folks will attempt to match to narrow
> their search.
>
> Say someone tries searching the "Doe" DB to see if their missing person
> matches someone who was found, yet unidentified. They might attempt to
match
> several criteria such as:
>
> * male
> * 45 yrs
> * missing city
> * with various traits
>
> Possibly several other specific details. Most all the fields are
individual
> ones, although the distinguishing marks fields is a memo field!
>
> Anyone have a clue on how this should be handled, outside of a huge
> ...OR...statement???
>
> TIA for any info...
>
> Dian ~
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.740 / Virus Database: 494 - Release Date: 16/08/2004
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~->
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [EMAIL PROTECTED]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/active-server-pages/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/