If you typed that in, would your database accept it? That doesn't look valid to me. I would expect something more like:

WHERE ... AND ((CLName LIKE 'A%') OR (CLName in ('MET-CL1','BDO-CL1'))

The following will divide the provided values into two arrays, @pre to hold prefixes, @words to hold complete values. It assumes one letter by itself is a prefix. Anything else is a complete value.

if ($clnm) { @parts = split /,/,$clnm; map { m/\'\w\'/ ? push @pre, $_ : push @words, $_ } @parts;

Functions like join can be used to format the LIKE clause and the IN clause. Here's one way to construct the IN clause:

$in_clause = sprintf "( CLName IN (%s) )", join ',',@words;

Then you will need some logic to figure out what connecting terms (AND, OR) you will need.

Dum Spiro Spero

In reply to Re^7: wild cards in Vertica by GotToBTru
in thread wild cards in Vertica by pragov

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.