in reply to Re^6: wild cards in Vertica
in thread wild cards in Vertica

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