1

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

2
  • 1
    The 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
    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
    Aug 9, 2021 at 14:49

1 Answer 1

-1

I solve this problema using MySQL JSON_TABLE – Map a JSON object to a relational database table.

Cheers

1
  • 1
    Some detail and implementation specifics would be welcome. Sep 30, 2021 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.