I have a table which has a column with nested JSON data that I want to read for a query result. But the data type of column is VARCHAR and data inside is a JSON string with nested objects inside.
Now when I hit below query it works fine and gives me result,
select * from dataTable where regexp_like(metadata,'(*)"id":"33001"(*)');
Below is the metadata column of dataTable :
{"id":"33001",
"digits":"1234",
"requestId":"5d54-f6-48-8d-8155190",
"deliveryMethod":"ATT",
"messageStatus":"{\"status\":[
{\"tokenId\":\"Zktx\",\"deliveryStatus\":\"SUCCESS\",\"code\":\"0\"},
{\"tokenId\":\"aGsx\",\"deliveryStatus\":\"SUCCESS\",\"code\":\"0\"}
]}"
}
Above data is all String in single metadata column, I have split it just so that it is more readable.
But I also want to filter the data based on "deliveryStatus" contents. So when I try below query,
select * from dataTable where regexp_like(metadata,'(*)"id":"33001"(*)') AND regexp_like(metadata,'(*)\"deliveryStatus\":\"SUCCESS\"(*)');
It doesn't work. Does NOT show any result. There is no error though. I feel I need some other approach to read the nested JSON contents inside that string. But I am not sure how to do that.
Can someone provide any insights of how to achieve this?