By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
SELECT VERSION();
VERSION() |
---|
10.2.16-MariaDB-10.2.16+maria~jessie-log |
SET @`json` := '["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]',
@`value` := 'AB';
SELECT JSON_SEARCH(@`json`, 'one', 'AB');
JSON_SEARCH(@`json`, 'one', 'AB') |
---|
"$[2].C" |
SELECT JSON_SEARCH('["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', 'one', 'AB');
JSON_SEARCH('["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', 'one', 'AB') |
---|
"$[2].C" |
SELECT JSON_SEARCH('["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', 'one', @`value`);
JSON_SEARCH('["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', 'one', @`value`) |
---|
"$[2].C" |
SELECT JSON_SEARCH(@`json`, 'one', 'AB');
JSON_SEARCH(@`json`, 'one', 'AB') |
---|
"$[2].C" |
SELECT JSON_SEARCH(@`json`, 'one', @`value`);
JSON_SEARCH(@`json`, 'one', @`value`) |
---|
null |
SHOW WARNINGS;
Level | Code | Message |
---|---|---|
Warning | 4038 | Syntax error in JSON text in argument 1 to function 'json_search' at position 1 |
SELECT JSON_SEARCH(JSON_UNQUOTE(@`json`), 'one', @`value`);
JSON_SEARCH(JSON_UNQUOTE(@`json`), 'one', @`value`) |
---|
"$[2].C" |