我们将信息保存在一个 json 列中,该列包含一个数组中的 json 数据。
数据结构:
[
{
"type":"automated_backfill",
"title":"Walgreens Sales Ad",
"keyword":"Walgreens Sales Ad",
"score":4
},
{
"type":"automated_backfill",
"title":"Nicoderm Coupons",
"keyword":"Nicoderm Coupons",
"score":4
},
{
"type":"automated_backfill",
"title":"Iphone Sales",
"keyword":"Iphone Sales",
"score":3
},
{
"type":"automated_backfill",
"title":"Best Top Load Washers",
"keyword":"Best Top Load Washers",
"score":1
},
{
"type":"automated_backfill",
"title":"Top 10 Best Cell Phones",
"keyword":"Top 10 Best Cell Phones",
"score":1
},
{
"type":"automated_backfill",
"title":"Tv Deals",
"keyword":"Tv Deals",
"score":0
}
]
Run Code Online (Sandbox Code Playgroud)
我们正在尝试什么:
SELECT id, ad_meta->'$**.type' FROM window_requests
Run Code Online (Sandbox Code Playgroud)
返回:
我们希望将每种类型作为行,我认为这只能通过存储过程实现,返回整列,然后在每一行上运行循环并返回数据...
或者你能想到更好的解决方案吗?
更新架构:
或者我们应该更改我们的数据库并将信息保存在单独的表中而不是 json …