我:
在pgsql中使用
a.type in ( string_to_array( (select cii.type from cinfo cii where cii.cidx = a.cidx), ‘,’)
报错了 operator does not exist: character varying = text[]
GPT:
这个错误是因为 operator "varchr = text[] " 不存在,也就是“character varying”和“text[]”数据类型不能直接比较。
解决办法是将 “string_to_array” 转为与 "a.type " 相同的数据类型。可以使用ARRAY[type ]形式:
a.type = ANY(ARRAY[string_to_array(
(select
cii.type
from
cinfo cii
where
cii.cidx = a.cidx ), ',')])
这里的 ANY()
函数可以将数组展开为一个列表并进行比较,这样就可以避免数据类型不匹配的错误了。