此问题在此处已有答案:
JSONB in where clause postgres(2个答案)
how to query array of nested json in postgresql(2个答案)
3天前关闭。
我有一个包含jsonb products
列的postrgresql表:
| products |
| --------------------------------------------------- |
| [{"id": "eaaca8bc-c8a0-45f7-9698-d4fc701d2e5a", "@type": "@game", "extId": "da32af17-fa03-4a62-bd04-f026d04d16e9"}, {"id": "5fc5de21-9cb7-4bd3-a723-7936bfef7cde", "@type": "@book", "extId": "c945f005-2d37-491c-8ba9-9da2709a3aab"}, {"id": "892fe85c-d7d6-4815-8dec-1720b644205a", "@type": "@sport", "extId": "c252dcba-2a14-4e75-90db-29ccac2499d2"}] |
| [{"id": "gh6d86ls-wj8o-39r4-2694-1720b644205a", "@type": "@game", "extId": "da32af17-fa03-4a62-bd04-f026d04d16e9"}] |
| |
| [{"id": "892fe85c-d7d6-4815-8dec-1720b644205a", "@type": "@sport", "extId": "c252dcba-2a14-4e75-90db-29ccac2499d2"}] |
products
列中的pretty json示例:
[
{
"id": "eaaca8bc-c8a0-45f7-9698-d4fc701d2e5a",
"@type": "@game",
"extId": "da32af17-fa03-4a62-bd04-f026d04d16e9"
},
{
"id": "5fc5de21-9cb7-4bd3-a723-7936bfef7cde",
"@type": "@book",
"extId": "c945f005-2d37-491c-8ba9-9da2709a3aab"
}
]
如何选择"@type"
等于"@game"
且"extId"
等于da32af17-fa03-4a62-bd04-f026d04d16e9
的所有行?
1条答案
按热度按时间hvvq6cgz1#
可以使用包含运算符
@>