正则表达式运算符给出错误运算符不存在:bigint~unknown

时间:2018-05-15 15:30:48

标签: sql postgresql

我是postgres的新手,并尝试使用正则表达式查找查询问题。

查询:

select name, ip_address, install_status 
from sn_cache_prod.cmdb_ci 
where support_group = 'bee96a2135a631007fa2c5751b2c74be'
and u_environment = 5 
and install_status ~ '(110|3)';

错误:

ERROR:  operator does not exist: bigint ~ unknown

install_status列定义为bigint

查询是否可以在不进行强制转换的情况下工作?

1 个答案:

答案 0 :(得分:1)

正则表达式适用于字符串(文本)值,不能用于数字。在您的情况下,您需要IN运算符:

select name,ip_address,install_status 
from sn_cache_prod.cmdb_ci 
where support_group = 'bee96a2135a631007fa2c5751b2c74be'
  and u_environment = 5 
  and install_status in (110,3);

相当于

and (install_status = 110 or install_status = 3)