我有以下行:
id | 产品日志 | 创建时间 |
---|---|---|
1 | <json字符串,见下文> | 2022-07-13 07:13:00 |
示例 json 数据:
{ "products": [ { "logs": [{ "log_time": "2022-07-13 01:30:00", "log_type": "manual", "log_info": "some text" }], "product_id": 123, "time": "2022-07-12 01:30:00" }, { "logs": [], "product_id": 124, "time": "2022-07-13 01:31:00" } ] }
例如搜索 product_id
124,它应该返回整行,但 json 字段只包含匹配的对象:
id | 产品日志 | 创建时间 |
---|---|---|
1 | {"logs":[],"product_id":124,"time":"2022-07-13 01:31:00"} |
2022-07-13 07:13:00 |
如果结果输出包含 json 的原始“形状”也很好:
{ "products": [ { "logs": [], "product_id": 124, "time": "2022-07-13 01:31:00" } ] }
P粉1291682062024-03-29 00:02:15
雷雷
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=26541a1e241be02680ba97a78f0791 c2一个>