I have a table with the below json data type column in a table TABLESDATA
create table tablesdata(sample json);
And I am using the sql to query the table.
select sample->>"$[*].name" as new_data from tablesdata WHERE sample ->>'$[*].name' = "EDFG";
The sample json data is like below
[
{
"name": "EDFG",
"isUsed": true,
"columns": [
{
"name": "Article_color_lookup_id",
"isUsed": false,
"dataType": "INTEGER"
},
]
},
{
"name": "ABCDE",
"isUsed": false,
"columns": [
{
"name": "Article_lookup_criteria_id",
"isUsed": false,
"dataType": "INTEGER"
},
]
},
.............so on
]
But the query is not returning any rows. What am I doing wrong here?
I need the output will be like
[
{
"name": "EDFG",
},
{
"name": "EDFG",
},
]
Can you please try using JSON search functions instead of where clause https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html
Like following some example
Search all items with the 'JavaScript' tag
Find all items with tags starting 'Java':