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

  • Please consider reading this advice. Also consider properly normalizing your data model. – mustaccio Jul 20 '20 at 17:43
  • 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 '20 at 17:56
  • @mustaccio are you suggesting having json columns implies improper normalization? – Chazt3n Mar 12 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.