Postgres加入阵列
我有几行的列。
id, bookName, authors
12323345, FatBook, {1,3}
我试图通过上一列中的值加入另一个表。 最后一列的类型是文本。
加入将无法正常工作
像这样的
join users u on u."Id" IN books.authors
join users u on u."Id" IN books.authors::text[]
预期结果
12323345, FatBook, 1,3, John, Mark
,还是
12323345, FatBook, (1)John, (3)Mark
我该怎么做?我稍后会加入。
I have a few rows with a column like this.
id, bookName, authors
12323345, FatBook, {1,3}
I am trying to join another table by values from the last column.
The type of the last column is text.
Joins won't work
like this
join users u on u."Id" IN books.authors
join users u on u."Id" IN books.authors::text[]
Expected results
12323345, FatBook, 1,3, John, Mark
or
12323345, FatBook, (1)John, (3)Mark
How do I do this? I will concatenate it later.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
某人可能很有用
我想这对于基于String_agg和子查询的
I guess it might be useful for someone
My solution based on string_agg and subquery