[thelist] ASP & SQL

Paul Cowan thelist at lists.evolt.org
Thu Sep 12 20:04:01 2002


Josua Olson wrote:

> No, bad, grrr...
>
> Just build one query. :-)
>
> But, make it a dynamic query, such as:

<snip>

or, build a query with something like:

SELECT fname, lname, location
 FROM employees
 WHERE
    ((fname = <varFName>) OR (<varFName> = '')) AND
    ((lname = <varLName>) OR (<varLName> = '')) AND
    ((location = <varLocation>) OR (<varLocation> = ''))

This would probably be the best way if you were using prepared
statements/stored procs in something like SQL Server, because the
DB can come up with a nice cached query plan for that, rather than
working it out again each time.

I'm a SQL Server guy, not an Access guy, so doing all this DB-side
may not help you at all. Might make for neater code though....

(oh, and if NULL values are an option, deal with accordingly)

Paul