Mysql:在 returns 中与 json_extract 一起使用时没有行
Mysql: where in returns no rows when used with json_extract
我对以下简单的陈述有些困惑。
create table Test(id integer, data json);
insert into Test(id, data) values(1, '{"name": "vova"}');
select * from Test
where json_extract(data, "$.name") IN ("vova", "mark");
这里selectreturns什么都没有。但是,如果我在数组中留下单个元素,查询 returns 预期的行:
select * from Test
where json_extract(data, "$.name") IN ("vova");
'json_extract'和'where in'好像不喜欢对方?或者我可能遗漏了什么?
这里有一个 link 和一个 example。当我 运行 在本地查询时,行为是相同的。
如果您尝试评估
json_extract(data, "$.name")
-> 这将导致 "vova"
意思是用双引号,将您的IN
运算符视为select字符串值,添加单引号。
select * from Test
where json_extract(data, "$.name") IN ('"vova"', '"mark"');
我对以下简单的陈述有些困惑。
create table Test(id integer, data json);
insert into Test(id, data) values(1, '{"name": "vova"}');
select * from Test
where json_extract(data, "$.name") IN ("vova", "mark");
这里selectreturns什么都没有。但是,如果我在数组中留下单个元素,查询 returns 预期的行:
select * from Test
where json_extract(data, "$.name") IN ("vova");
'json_extract'和'where in'好像不喜欢对方?或者我可能遗漏了什么?
这里有一个 link 和一个 example。当我 运行 在本地查询时,行为是相同的。
如果您尝试评估
json_extract(data, "$.name")
-> 这将导致 "vova"
意思是用双引号,将您的IN
运算符视为select字符串值,添加单引号。
select * from Test
where json_extract(data, "$.name") IN ('"vova"', '"mark"');