• mysql根据JSON字段内容查询数据


    原文:https://www.cnblogs.com/sensenh/p/15397864.html

    mysql5.7以上支持json的操作,以及增加了json存储类型
    一般数据库存储json类型的数据会用json类型或者text类型

    表数据

    表结构

    使用 字段->’$.json属性’进行查询条件

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

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

     更多方案:https://www.jb51.net/article/230855.htm

    。表数据

     

    select * from product where suit like '%"10001"%';
    #like方式不能使用索引,性能不佳,且准确性不足
    
    select * from product where suit LOCATE('"10001"', 'suit') > 0;
    # LOCATE方式和like存在相同问题
    
    select * from product where suit != '' and json_contains('suit'->'$.hotel', '"10001"');
    #以MySQL内置json函数查找,需要MySQL5.7以上版本才能支持,准确性较高,不能使用全文索引
    
    select * from product where MATCH(suit) AGAINST('+"10001"' IN BOOLEAN MODE);
    #可使用全文索引,MySQL关键字默认限制最少4个字符,可在mysql.ini中修改 ft_min_word_len=2,重启后生效
  • 相关阅读:
    MIRO校验过程
    SAP中寄售处理
    物料BOM和生产订单BOM的区别
    sap 中怎样把非限制库存转为销售订单库存?
    SAP MM Consignment 寄售库存
    SAP 库存关联表信息
    SAP 物料主数据屏幕增强
    __defineGetter__ && __defineSetter__
    mongodb(分片)
    mongodb(副本集)
  • 原文地址:https://www.cnblogs.com/zagwk/p/15739321.html
Copyright © 2020-2023  润新知