SPUG: sql select on the fly

Martin Korb mkorb at versuslaw.com
Thu Jun 21 18:52:26 CDT 2001

I have a question concerning creating a sql-select statement on the fly. 

The user has a choice of any combination of 4 fields (either one or all 4). What is an elegant way to create a sql - select query based on the fields the user fills out.
my $file = param(Filename);
my $author = param(Author);
my $date = param(Date);

my $select_query = "Select * from table where filename =\'$file\' and author =\'$author\'";

#####    I know I an do it in a round about way by using

if ($file) {
    push @array, "filename =\'$file\' and "; 

and then do a join on the @array elements. 

Are there better ways to handle this?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20010621/2014da6e/attachment.htm

More information about the spug-list mailing list