mysql8之json类型使用

  • 向json类型字段添加数据

json字段为present

    <update id="updateMeetingPresent" parameterType="HashMap">
        UPDATE tb_meeting
        SET present = JSON_ARRAY_APPEND ( IFNULL( present, JSON_ARRAY() ), '$', #{userId} )
        WHERE id = #{meetingId}
        AND NOW() >= DATE_SUB(CONCAT(date," ",`start`), INTERVAL 15 MINUTE)
        AND NOW() &lt; DATE_SUB(CONCAT(date," ",`end`),INTERVAL 15 MINUTE)
        AND JSON_CONTAINS ( IFNULL( members, JSON_ARRAY ( ) ), CAST( #{userId} AS CHAR ) )
        AND NOT JSON_CONTAINS ( IFNULL( present, JSON_ARRAY ( ) ), CAST( #{userId} AS CHAR ) )
    </update>

猜你喜欢

转载自blog.csdn.net/qq_39940205/article/details/121060451