Postgresql - 与 string_agg 相反

Sup*_*ero 6 sql postgresql unnest

我正在寻找一个 postgresql 函数,它将与string_agg.

我有一个电影表,其中标签列包含诸如

Action|Adventure|Drama|Horror|Sci-Fi
Action|Horror|Sci-Fi
Run Code Online (Sandbox Code Playgroud)

例如,我想从该列中获取不同的标签列表

Action
Adventure
Drama
Horror
Sci-Fi
Run Code Online (Sandbox Code Playgroud)

Gor*_*off 6

您可以使用unnest()string_to_array()

 select unnest(string_to_array(t.col, ','))
 from t
Run Code Online (Sandbox Code Playgroud)