PostgreSQL-与string_agg相反 [英] Postgresql - Opposite of string_agg
本文介绍了PostgreSQL-与string_agg相反的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一个与 string_agg
相反的postgresql函数。
I'm looking for a postgresql function that will do the opposite of string_agg
.
我有一个电影表,其中的tag列包含诸如
I have a movies table where the tags column contains values such as
Action|Adventure|Drama|Horror|Sci-Fi
Action|Horror|Sci-Fi
我想从此列中获得不同的标签列表,例如
I would like to get a distinct list of tags from this column, for example
Action
Adventure
Drama
Horror
Sci-Fi
推荐答案
您可以使用 unnest()
和 string_to_array()
:
select unnest(string_to_array(t.col, ','))
from t
这篇关于PostgreSQL-与string_agg相反的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文