2

I just try to get path of value using JSON_SEARCH function:

SELECT JSON_SEARCH('[12, 13, {"12": 123}]', 'one', '123', null, '$[*]') path;

When I run this query in MariaDB it works and I got desired result

+===========+
| path      |
+===========+
| "$[2].12" |
+-----------+

but run same query on top MySQL 8.0 I got NULL

So I need help how to match the query for use it with MySQL

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39

1 Answers1

3

Bug #79233: JSON_SEARCH does not search for non-string values

If your JSON scalar values are strings, you can find them:

mysql> SELECT JSON_SEARCH('[12, 13, {"12": "123"}]', 'one', '123', null, '$[*]') path;
                                           ^^^^^ quoted string value
+---------------+
| path          |
+---------------+
| "$[2].\"12\"" |
+---------------+
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828