hakki
hakki

Reputation: 6527

How to search JSON array field in MySQL?

I have a column which has json type arrays like

row1: ["abc", 10, null, true, false]
row2: ["def", 10, null, true, false]

How can i use where clause to find "abc" contained rows? My json arrays has no key. They only have values.

select * from myTable where JSON_SEARCH(myColumn,"all","abc")

returns 0 rows

Upvotes: 1

Views: 114

Answers (1)

GMB
GMB

Reputation: 222652

You can use MySQL JSON search function JSON_CONTAINS():

where json_contains(myColumn, '"abc"')

Upvotes: 1

Related Questions