我有以下行:
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一个>
#