[SOLVED] How to check value in JSON?

Issue

I need to check if the value is in this JSON field

SELECT * FROM my_table WHERE JSON_EXTRACT(my_column, '$[*]') = 1

OR

SELECT * FROM my_table WHERE 1 IN (JSON_EXTRACT(my_column, '$[*]'))

My field: [1,2,3,4]

RESOLUTION WORK:

SELECT * FROM my_table WHERE JSON_SEARCH(my_column, "one", "1") IS NOT NULL

Solution

SELECT * FROM my_table WHERE JSON_SEARCH(my_column, "one", "1") IS NOT NULL

Answered By – Mateusz Chmielnicki

Answer Checked By – Willingham (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.