[thelist] ASP & SQL

Joshua Olson joshua at waetech.com
Thu Sep 12 20:12:01 CDT 2002


----- Original Message -----
From: "Paul Cowan" <evolt at funkwit.com>
Sent: Thursday, September 12, 2002 9:01 PM


> 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.

Indeed.  Except that the expense of OR's is quite high.  If dynamically
generating the query was not an option, I'd definitely use something like
you siggested.

> 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....

I agree 100%.

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

Yeah, that makes it even uglier.  :-)

-joshua




More information about the thelist mailing list