I am very much struggling in MYSQL when it comes to query JSON type column, this time I need to put where condition on a JSON type field.
JSON type value in my user table is like this: {"id": ["2", "4"]}
When I query a SELECT on my table like:
SELECT json_extract(gids, '$.id') from users
Its outputs like this:
["2", "4"]
I am required to write a query where I need to get all users where id=2
I have tried somthing like this:
SELECT *
FROM users
WHERE json_extract(gids, '$.id')="2"
But its not working, Please help on this as I am stuck here.
Thanks
WHERE JSON_OVERLAPS(JSON_EXTRACT(gids, '$.id'), '["2"]')?