如何使用 cte 进行模式匹配?
我尝试过以下操作:
with cte1 as (
select '''' || '{' || accountids || '}' || '''' as accountids
from table_a
where email = '[email protected]'
)
select id
from table_a
where accountids ^@ ANY (select accountids from cte1);
我希望结果集返回 a12 和 c45。这可能吗?
看起来您可能想要将您的转换
accountids
为数组并使用重叠&&
运算符。不清楚您使用 的意图
^@
,或者希望如何输出ANY
子查询的结果。您需要的是连接。db<>小提琴
你最好以正确的方式存储你的数据。那么你的查询将如下所示