sql - 从字符串中的名称值对中获取一个值
问题描述
对于以下示例,返回帐户 ID 123abc 的最佳方法是什么?
with
pairs as (
select 'blah=foo|something=else|account_id=123abc|fruits=apples' pears
)
select [I want account_id] from pairs
解决方案
一种方法使用regexp_matches()
:
select (regexp_matches(pears, 'account_id=([^|]+)'))[1]
from pairs
推荐阅读
- rust - 这是按值捕获字符串的正确方法吗?
- javascript - 如何单击 SVG 以激活父网页中的功能
- html - 导航栏中文本上方的下拉箭头
- django - django+react 应用部署到 Heroku 时 TemplateDoesNotExist at / index.html 出错
- sql - 修改时间戳并选择当前日期
- python - Pandas 多列比较
- java - 查找给定的数字是否是完全平方?
- machine-learning - 如何为 q-learning 设置状态空间?
- xcode - Flutter,pubspec.yaml 文件显示一些错误
- c# - docker run:无法执行,因为找不到指定的命令或文件