By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
select version();
version() |
---|
10.4.7-MariaDB-1:10.4.7+maria~buster |
create table myjson(data json);
insert into myjson values ('{"foo": "bar"}');
insert into myjson values ('"bar"');
select * from myjson where json_extract(data, '$.foo') = json_extract('"bar"', '$');
select * from myjson where json_extract(data, '$.foo') = json_unquote(json_extract('"bar"', '$'));
data |
---|
{"foo": "bar"} |
select * from myjson where json_unquote(json_extract(data, '$.foo')) = json_extract('"bar"', '$');
select * from myjson where json_unquote(json_extract(data, '$.foo')) = json_unquote(json_extract('"bar"', '$'));
data |
---|
{"foo": "bar"} |
select * from myjson where json_extract(data, '$') = 'bar';
data |
---|
"bar" |
select * from myjson where json_unquote(json_extract(data, '$')) = 'bar';
data |
---|
"bar" |
select json_extract('"bar"', '$');
json_extract('"bar"', '$') |
---|
"bar" |
select json_unquote(json_extract('"bar"', '$'));
json_unquote(json_extract('"bar"', '$')) |
---|
bar |
select json_extract('{"foo": "bar"}', '$.foo');
json_extract('{"foo": "bar"}', '$.foo') |
---|
"bar" |
select json_unquote(json_extract('{"foo": "bar"}', '$.foo'));
json_unquote(json_extract('{"foo": "bar"}', '$.foo')) |
---|
bar |
select json_extract('{"foo": "bar"}', '$.foo') = json_extract('{"foo": "bar"}', '$.foo');
json_extract('{"foo": "bar"}', '$.foo') = json_extract('{"foo": "bar"}', '$.foo') |
---|
0 |
select json_unquote(json_extract('{"foo": "bar"}', '$.foo')) = json_unquote(json_extract('{"foo": "bar"}', '$.foo'));
json_unquote(json_extract('{"foo": "bar"}', '$.foo')) = json_unquote(json_extract('{"foo": "bar"}', '$.foo')) |
---|
1 |
select json_extract('{"foo": "bar"}', '$.foo') = json_unquote(json_extract('{"foo": "bar"}', '$.foo'));
json_extract('{"foo": "bar"}', '$.foo') = json_unquote(json_extract('{"foo": "bar"}', '$.foo')) |
---|
0 |
select json_unquote(json_extract('{"foo": "bar"}', '$.foo')) = json_extract('{"foo": "bar"}', '$.foo');
json_unquote(json_extract('{"foo": "bar"}', '$.foo')) = json_extract('{"foo": "bar"}', '$.foo') |
---|
0 |
select json_extract('{"foo": "bar"}', '$.foo') = json_unquote(json_extract('"bar"', '$'));
json_extract('{"foo": "bar"}', '$.foo') = json_unquote(json_extract('"bar"', '$')) |
---|
0 |
# If the above is false, then how come this yields a result?
select * from myjson where json_extract(data, '$.foo') = json_unquote(json_extract('"bar"', '$'));
data |
---|
{"foo": "bar"} |