MySQL的json查询之->、->>、json_extract、json_unquote
作者:互联网
表数据(member)
id | info |
---|---|
1 | {“id”:1,“name”:“swk”} |
2 | {“id”:2,“name”:“zbj”} |
3 | {“id”:3,“name”:“ss”} |
4 | {“id”:4,“name”:“ts”} |
例一,在field中使用
->在field中使用的时候结果带引号,->>的结果不带引号
select info->"$.name" from member;
select info->>"$.name" from member;
例二,在where条件中使用
特别注意:->当做where查询是要注意类型的,->>是不用注意类型的
select * from member where info->"$.id" = 1;
select * from member where info->"$.id" = "1";
select * from member where info->>"$.id" = 1;
select * from member where info->>"$.id" = "1";
例三,在order中使用
没有发现有什么区别
select * from member order by info->"$.id" desc;
select * from member order by info->>"$.id" desc;
标签:unquote,info,name,where,member,json,extract,id,select 来源: https://blog.csdn.net/ai274575257/article/details/121963244