到目前为止我发现的是
select ARRAY(
select unnest(ARRAY[ 'a', 'b', 'c' ])
except
select unnest(ARRAY[ 'c', 'd', 'e' ])
)
我们可以这样做来仅查找两个字符串数组之间的不匹配元素。
还有其他最好的方法吗?
就像整数数组一样,我们可以这样做
SELECT int[1,2,3] - int[2,3]
最佳答案
select array_agg(e order by e)
from (
select e
from
(
select unnest(array[ 'a', 'b', 'c' ])
union all
select unnest(array[ 'c', 'd', 'e' ])
) u (e)
group by e
having count(*) = 1
) s
关于postgresql - 在 postgresql 中仅查找两个字符串数组之间不匹配元素的最佳方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15067128/