• mysql 5.7新特新 操作json 数组


    select * from  EDI.edi_history where id = 2577;
    
    UPDATE EDI.edi_history SET response_summary = JSON_REPLACE(response_summary, '$[0].isOverMileStone', 'php') WHERE id = 2577;

    对于json数组,使用$[*]  然后在获取节点.

     


    @Query(value = "select * from EDI.edi_history where json_contains(response_summary, ?1) and json_contains(response_summary, ?2) and json_contains(response_summary, ?3) and json_contains(response_summary, ?4)", nativeQuery = true)
    public List<EdiHistoryDO> findByResponseSummary(String result, String orderNo, String orderId, String docType);


    // UPDATE EDI.edi_history SET response_summary = JSON_REPLACE(response_summary,
    // '$[0].isOverMileStone', 'true')
    // WHERE
    // json_contains(response_summary, '{"courierBillNo":"159900000091"}')
    // and json_contains(response_summary, '{"result":"SUCCESS"}')
    // and response_summary like "%dest_stn%" ;
    @Modifying(clearAutomatically = true)
    //@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
    @Query(value = " UPDATE EDI.edi_history SET response_summary = JSON_REPLACE(response_summary, '$[0].isOverMileStone', ?1) "
    + " WHERE " + " json_contains(response_summary, ?2) "
    + " and json_contains(response_summary, '{"result":"SUCCESS"}') "
    + " and response_summary like "%dest_stn%"", nativeQuery = true)
    public int updateResponseSummaryIsOverMileStoneByCourierBillNo(String trueOrfalse, String courierBillNoJson);


    /**
    * get id from ediHistory which include milestone info
    */
    @Query(value = " select id from EDI.edi_history "
    + " WHERE " + " json_contains(response_summary, ?1) "
    + " and json_contains(response_summary, '{"result":"SUCCESS"}') "
    + " and response_summary like "%dest_stn%"", nativeQuery = true)
    public BigInteger findEdiHistoryId(String courierBillNoJson);

  • 相关阅读:
    开发软件设计模型 visual studio UML
    to debug asp.net mvc4
    BeeFramework
    .net entity framework 泛型 更新与增加记录
    javascript debut trick, using the throw to make a interrupt(breakpoint) in your program
    C# dynamic
    webapi
    C# async / await
    NYoj 613 免费馅饼
    洛谷P1056:排座椅(贪心)
  • 原文地址:https://www.cnblogs.com/lshan/p/9184924.html
Copyright © 2020-2023  润新知