I have a json column in MySQL which contains a list of items for eg.
"style": {"style1", "style2", "style3", "style4", "style5"}
I want to search all the rows which contain the styles I specify through an array like IN clause like WHERE style IN(["style1", "style3"])
So I want to get all the rows which will match the string items from array exactly like how the WHERE IN()
clause works in MySQL.
Is there any workaround or easy way to get this working?
Please help.. Thanks
-
1The tables and models have already been setup and I don't have any control over it. I was looking for JSON_CONTAINS, JSON_SEARCH but could not find a satisafactory solution. I have updated the question and added a little more description of what I want.girish– girish2020年07月20日 17:56:39 +00:00Commented Jul 20, 2020 at 17:56
-
Small point of order, but your example JSON should use [] instead of {}. Just in case that's compounding the issue...Andrew– Andrew2021年08月09日 14:49:51 +00:00Commented Aug 9, 2021 at 14:49
1 Answer 1
I solve this problema using MySQL JSON_TABLE – Map a JSON object to a relational database table.
Cheers
-
1Some detail and implementation specifics would be welcome.Michael Green– Michael Green2021年09月30日 05:46:39 +00:00Commented Sep 30, 2021 at 5:46