Postgre数据库Jsonb字段json条件过滤

JSON列表过滤

{
    "threshold": [
        {
            "end_time": null,
            "end_period": null,
            "start_time": null,
            "start_period": null,
            "low_threshold": null,
            "high_threshold": null,
            "threshold_type": "GLOBAL",
            "too_low_threshold": -2,
            "too_high_threshold": 9
        },
        {
            "end_time": "09-30  23:59:59",
            "end_period": "23:59:59",
            "start_time": "06-01  00:00:00",
            "start_period": "00:00:00",
            "low_threshold": null,
            "high_threshold": null,
            "threshold_type": "TIMING",
            "too_low_threshold": 5,
            "too_high_threshold": 8
        },
        {
            "end_time": "05-03  23:59:59",
            "end_period": "09:58:59",
            "start_time": "01-01  00:00:00",
            "start_period": "00:00:00",
            "low_threshold": 2,
            "high_threshold": 3,
            "threshold_type": "TIMING",
            "too_low_threshold": 1,
            "too_high_threshold": 5
        },
        {
            "end_time": "05-03  23:59:59",
            "end_period": "23:59:59",
            "start_time": "01-01  00:00:00",
            "start_period": "09:59:00",
            "low_threshold": null,
            "high_threshold": null,
            "threshold_type": "TIMING",
            "too_low_threshold": 2,
            "too_high_threshold": 6
        },
        {
            "end_time": "12-31  23:59:59",
            "end_period": "23:59:59",
            "start_time": "10-01  00:00:00",
            "start_period": "00:00:00",
            "low_threshold": null,
            "high_threshold": null,
            "threshold_type": "TIMING",
            "too_low_threshold": 1,
            "too_high_threshold": 7
        }
    ]
}

SELECT * from idp_measure_point where alarm_config_json is not null and json_extract_path(alarm_config_json::json#>'{threshold, 1}', 'threshold_type')::text='"TIMING"' ORDER BY create_time desc;

Mybatis 里SQL写法,json字段过滤

 <select id="selectPushDataList" resultMap="BaseResultMap" parameterType="com.jpc.JpushData" >
    SELECT
      <include refid="Base_Column_List" />
    FROM
        jp_push jpt
    <where>
      delete_flag=1
      and (jpt.rule ->> 'sendType' )::text = 'tag'
      <if test="name != null and name !=''" >
        and name =#{name,jdbcType=VARCHAR}
      </if>
      ORDER BY
        create_time ASC
         LIMIT ${pageSize} OFFSET ${(currentPage - 1) * pageSize}
    </where>
  </select>

参考文章

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值