I'm working with MySQL and I have a table named course_definition
which has a column named cod_subject_ids
and it's a JSON type format and holds data like this:
[ "237", "5074" ]
Now I need to search in this column for specific number such as 237
which already exists.
I tried several ways but none of these return the result:
SELECT *
FROM course_definition
WHERE JSON_EXTRACT(cod_subject_ids, '$.237') IS NOT NULL;
SELECT *
FROM `course_definition`
WHERE JSON_EXTRACT(cod_subject_ids, '$."237"') IS NOT NULL;
SELECT *
FROM `course_definition`
WHERE FIND_IN_SET('237', REPLACE(cod_subject_ids, ' ', '')) > 0;
All of these syntaxes returns null result however the data 237 already exists there!
So how to find the columns that has this data in their json type format of cod_subject_ids
field?