【发布时间】:2017-10-20 19:23:50
【问题描述】:
在我的表中,我有一个名为 facebook 的列,其类型为 text[],其中包含数组。例如:
{{total_count,26861},{comment_count,94},{comment_plugin_count,0},{share_count,26631},{reaction_count,136}}
我将我的数据库与数据表一起使用,当我尝试通过 facebook 对我的表进行排序时,我得到了这个:
这是错误的。所以我试图从这个数组中只获取 total_count 作为数值。现在我得到了这个:
regexp_matches(array_to_string(facebook, ' '), '(\d+).*')
但这会返回数组,例如:
所以我添加了 ::numeric
regexp_matches(array_to_string(facebook, ' '), '(\d+).*')::numeric
但我收到一个错误:
无法将类型文本[] 转换为数字
有什么解决办法吗?
【问题讨论】:
-
@lad2025 就是这么简单...非常感谢!!!
-
当然,我将其发布为答案 :)
标签: postgresql datatable