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

asked Jul 20, 2020 at 15:52
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. Commented 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... Commented 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

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.