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

The SQL is as follows $sql = $select.$from.$Where; $from is the list of fields from the table. and $Where is the filters. How do I tweak my program, to tell what is a prefix and what is a complete value? Thanks, Pragov

Replies are listed 'Best First'.
Re^3: wild cards in Vertica
by GotToBTru (Prior) on Jun 30, 2015 at 18:32 UTC

    What value do you want to be in $Where?

    As to how to tell what is prefix, I don't know enough about your data. Is a 1 letter entry always a prefix?

    You can always use LIKE and % but it will hurt the efficiency of your queries. That may not matter to you.

    Dum Spiro Spero
      Yes..the prefix is always like A or B or M etc. I tried this way
      if ($clnm ne ""){ $cnt = @parts = split(/\,/, $clnm ); # $clnm = "'"; $WHERE = $WHERE ." AND ("; for ($i = 0; $i < $cnt; $i++) { $WHERE = $WHERE . "m.CLNAME LIKE '$parts[$i]%' "; ($WHERE = $WHERE . " OR ") if ($i < $cnt - 1); } $WHERE = $WHERE . ")"; }
      but still did not work. getting output as: AND m.CLNAME IN (A,BDO-CL1) Should I modify here too?
      if ($clnm ne "") { $Where = $Where . "AND m.CLNAME IN ($clnm) "; }
      Thanks,

        Saying it doesn't work doesn't help. For the THIRD time, please answer my very simple question .. what value do you want to see in $Where?

        Dum Spiro Spero