我正在try 筛选出其中某个特定字段包含带有单词的特殊字符的记录.

例如:

-[ RECORD 1 ]--------------+------------------------------ 
id                         | 3151 
description                | Manual add from SCCM 
mac_address                | d4258be8d064 
status                     | Unknown 
mac_vendor                 | Intel Corporate 
added_by                   | Policy Manager 
added_at                   | 2019-02-19 14:29:21.802413+00 
updated_at                 | 2022-10-19 10:57:15.960282+00
attributes                 | {"Our Device": "true"}
extras                     |  
org_id                     | 1 
permit_id                  | 1
agentless_managed_endpoint | 0

我试过了

select * 
from tips_endpoints 
where description = 'Manual add from SCCM' 
AND attributes = '{"Our Device": "true"}';

但它失败了.

我需要能够找到属性值为{"Our Device":"True"}的记录

推荐答案

试试这个:

select * 
from tips_endpoints 
where description = 'Manual add from SCCM' 
  AND attributes Like '%{"Our Device": "true"}%';

UPD, for Postgres:

select * 
from tips_endpoints 
where description = 'Manual add from SCCM' 
  AND attributes::text Like '%{"Our Device": "true"}%';

Postgresql相关问答推荐

哪种数据类型是除法的结果?

是否可以在psql查询输出中删除新行末尾的+号?

自左联接的POSTGIS更新

在插入时创建一个触发器,在PostgreSQL中的另一个表上创建另一个触发器

当参数大小超过 393166 个字符时,PSQL 准备语句查询挂起

使用psql的copy语句时如何压缩数据?

PG::UndefinedTable:错误:relation "active_storage_blobs" does not exist

!= 和 <> 运算符有什么区别?

如何在可选参数上查询 postgres?

PostgreSQL CASE 在函数中的使用

如何使用 node-postgres 将多行正确插入 PG?

在 postgresql 中,如何在 jsonb 键上返回布尔值而不是字符串?

为 postgresql 存储过程设置隔离级别

使用 Spring、Hibernate 和 C3P0 管理多租户 Web 应用程序中的连接池

如何在 postgres 查询中排名

与 iexact 一起使用时,Django get_or_create 无法设置字段

psql 将默认 statement_timeout 设置为 postgres 中的用户

PostgreSQL regexp_replace() 只保留一个空格

用于将布尔列排序为 true、null、false 的 SQL

基于秒的 Postgresql 日期差异