[thelist] To Store or Not to Store - Building dynamic queries

Ed McCarroll Ed at ComSimplicity.com
Fri Aug 11 12:23:09 CDT 2006


> my question is, how do I build a stored procedure that will allow
> for one or multiple WHERE statements.

One way I've used is to have a default value like a zero or an empty
string that gets passed when a criteria isn't specified.

SELECT * FROM listings
 WHERE (name LIKE @company_name OR @company_name = '')
   AND (address LIKE @address OR @address = '')
   ...

-------------------------------------------------------------------- 
Ed McCarroll                                          (310) 838-4330
Ed at ComSimplicity.com                    http://www.ComSimplicity.com



More information about the thelist mailing list