I have a table with a column (column_metadata) that holds a json array
[{
"ORDER": -1,
"READONLY": false,
"COLUMNNAME": "id",
"COLUMNTYPE": "int",
"FILTERABLE": false,
"SUMMARYVIEW": false,
"WHITELISTED": false
},
{
"ORDER": -1,
"READONLY": true,
"COLUMNNAME": "name",
"COLUMNTYPE": "varchar",
"FILTERABLE": true,
"SUMMARYVIEW": true,
"WHITELISTED": true
},
{
"ORDER": -1,
"READONLY": false,
"COLUMNNAME": "description",
"COLUMNTYPE": "varchar",
"FILTERABLE": true,
"SUMMARYVIEW": true,
"WHITELISTED": true
}]
I am trying to get all COLUMNNAME
list for where WHITELISTED
is true.
I got select json_extract(column_metadata, '$[*].COLUMNNAME') from myTable
that returns me all the column names returned separated by comma.
However, when I add a where clause
select json_extract(column_metadata, '$[*].COLUMNNAME') from myTable
WHERE json_extract(column_metadata, '$[*].WHITELISTED') = true;
it doesn't return anything. How do we construct the where clause with json_extract?
EDIT: I am using MySQL 5.7 so JSON_TABLE() isn't available