database - 单个 Postgres 数据库表列中的多个值
问题描述
我最近接任了一个我不熟悉的应用程序的数据库管理员。我正在探索开发数据库实例,并在单个列中找到了一个包含多个值的表。我不确定如何查询此列,因为到目前为止我尝试过的方法都没有奏效。
我在列名和列值本身中看起来像键值对的内容之间尝试了各种字符。我正在尝试根据 state :name 值进行选择。以下都没有工作,我还没有找到解决这个问题的 postgres 文档。
select * from district where state = 'California';
select * from district where state:name = 'California';
select * from district where state_name = 'California';
select * from district where state[name] = 'California';
select * from district where state[:name] = 'California';
select * from district where state[0] = 'California';
以下是来自表区的特定条目
id | 8
name | 13
state | --- + | :name: California + | :abbr: CA + |
created_at | 2011-12-08 04:31:15.104002
updated_at | 2011-12-08 04:31:15.104002
解决方案
尝试正则表达式:
WHERE name ~ '\mCalifornia\M'
推荐阅读
- macos - Mac/Linux 命令:从任何地方访问?
- javascript - 正则表达式允许中文或字母字符
- java - 如何编写 Do/While 验证?
- c - 与 OpenGL ES 渲染和 windows 多线程冲突
- angular - 删除方法中的 HTTP 错误无法正常工作
- c# - Asp Net Core MVC Identity Dapper 获取所有用户
- sql - 在sql中将varchar转换为日期时间
- jquery - 使用 customEvent 将 JSON 数据列表从一个组件发送到另一个组件
- php - 如何将变量从python传递到php?
- c++ - 如何声明异步函数?