有一个表,其列类型为 jsonb。
{
"key1":
[
{"file": "U2323.DAT", "tt_date": "2023-12-03 22:22:12"},
{"file": "V000.DAT", "tt_date": "2025-12-03 22:22:12"}
]
}
有一个获取某些元素的所有数据的请求。
select
jsonb_array_elements(status->'key1')->>'file' as file,
jsonb_array_elements(status->'key1')->>'tt_date' as tt_date
from status;
如何添加条件来获取file
值以“U2”开头的元素?不清楚如何访问条件中的特定数组元素并设置条件。
将集合返回函数作为显式连接调用,而不是在 select 中隐式使用它