1

I have a MySQL column with below data:

{
  "ids": [
    "c9cfdecc-dfce-11eb-8c94-0ad691f61ea0",
    "c9cfdecc-dfce-11eb-8c94-0ad691f61ea1",
    "c9cfdecc-dfce-11eb-8c94-0ad691f61ea2"
  ]
}

How can I get records that matched with any requested string?

I tried below queries but no use:

SELECT * from test WHERE JSON_CONTAINS(fragments, '"c9cfdecc-dfce-11eb-8c94-0ad691f61ea1"', '$')

SELECT * from test WHERE JSON_CONTAINS(fragments, '"c9cfdecc-dfce-11eb-8c94-0ad691f61ea1"')

SELECT * from test WHERE JSON_SEARCH(fragments, 'one', "c9cfdecc-dfce-11eb-8c94-0ad691f61ea1")
halfer
  • 19,824
  • 17
  • 99
  • 186
Gowri
  • 1,832
  • 3
  • 29
  • 53
  • 2
    the last works for me: https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=e42e6685570b046444e03ee24b78f6d4 though apparently you can't test the result of JSON_SEARCH directly in mariadb and need to do it like https://dbfiddle.uk/?rdbms=mariadb_10.6&fiddle=800de37e2ea68585cc951e0748fe61c9 – ysth Oct 21 '21 at 05:01

0 Answers0