admin 评论(0) 2021-06-08 数据库

SELECT JSON_EXTRACT (teachers, '$[*].id') FROM lq_curriculum;

SELECT JSON_EXTRACT (teachers, '$[0].id') FROM lq_curriculum;

select * from lq_curriculum where JSON_CONTAINS(teachers,JSON_OBJECT('id', "22"))

还有FIND_IN_SET


  1. 使用 字段->'$.json属性'进行查询条件
  2. 使用json_extract函数查询,json_extract(字段,"$.json属性")
  3. 根据json数组查询,用JSON_CONTAINS(字段,JSON_OBJECT('json属性', "内容"))

select  * from log where data->'$.id' = 142;


 select data->'$.id' id,data->'$.name' name from log where data->'$.id' = 142;


select * from log2 where JSON_CONTAINS(data,JSON_OBJECT('id', "142"))

更多:https://blog.csdn.net/qq_21187515/article/details/90760337


https://blog.csdn.net/szxiaohe/article/details/82772881


评论
    你来打破0评论