Assuming you are talking about "Query by Example" another standard way, that has the main advantage of being very readable and easy to maintain is quite the following. But it only works good, if it is also O.K. to work with the LIKE statement:
# I assume the database handler $dbh is already initialized my $sth = $dbh->prepare(" SELECT * FROM table WHERE field1 LIKE ? AND field2 LIKE ? AND field3 LIKE ? AND field4 LIKE ? AND field5 LIKE ? "); for ($field1, $field2, $field3, $field4, $field5) { $_ = "" unless defined $_; $_ .= "%"; } $dbh->execute($field1, $field2, $field3, $field4, $field5); # But please choose better names than $fieldX :-)

Greetings,
Janek


In reply to Re: Database queries w/lots of inputs. by bigj
in thread Database queries w/lots of inputs. by elam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.