My data looks like this (table name: test_table):
{
timestamp: 'some_timestamp',
headers: [{'name': 'test', 'value': 'sth'}, {'name': 'test2', 'value': 'sth2'}, {'name': 'test3', 'value': 'sth3'}]
}
How can I select only {'name': 'test2', 'value': 'sth2'}
dynamically, ie. where condition is: name
needs to have value oftest2
and we don't know which object it is within the array.
I've tried:
SELECT JSON_SEARCH(headers, 'one', 'test2', NULL, '$[*].name') IS NOT NULL
FROM test_table