LIKE 模式匹配

Vertica 支持子查询中的 LIKE 模式匹配条件,并采用以下格式:

string-expression [ NOT ] { LIKE | ILIKE | LIKEB | ILIKEB } string-expression

以下命令搜索公司名称以“Ev”开头的客户,然后返回总计数:

=> SELECT COUNT(*) FROM customer_dimension WHERE customer_name LIKE
      (SELECT 'Ev%' FROM customer_dimension LIMIT 1);
 count
-------
   153
(1 row)

Vertica 还支持将单行子查询用作 LIKEB 谓词和 ILIKEB 谓词的模式实参,例如:

=> SELECT * FROM t1 WHERE t1.x LIKEB (SELECT t2.x FROM t2);

以下符号可替代 LIKE 关键字:

~~    LIKE
~#    LIKEB
~~*   ILIKE
~#*   ILIKEB
!~~   NOT LIKE
!~#   NOT LIKEB
!~~*  NOT ILIKE
!~#*  NOT IILIKEB

有关其他示例,请参阅 LIKE 谓词