Below is my json
data which is saved in cold_storage_data
column of inventory
table
[{
"qty_in_storage": "10",
"cold_storage_id": "2",
"cold_storage_lot_number": "678678"
}, {
"qty_in_storage": "15",
"cold_storage_id": "1",
"cold_storage_lot_number": "678679"
}]
Now I want to retrieve the data based on the cold_storage_lot_number
. So I have tried below solutions but none of them are working for me
SELECT
*
FROM
test.inventories
WHERE
JSON_EXTRACT( cold_storage_data, "$.cold_storage_lot_number" ) = "678679";
SELECT
*
FROM
test.inventories
WHERE
json_contains( cold_storage_data, "678679", "$.cold_storage_lot_number" );
SELECT
*
FROM
test.inventories
WHERE
cold_storage_data->"$.cold_storage_lot_number" = "678679";
Where I am going wrong?
The query provided by @dai dbfiddle working fine with mysql version 8
when I am testing it with MariaDB version 10.3.35
it is not working.
MariaDB dbfiddle