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() < 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>
标签:mysql8,userId,JSON,IFNULL,json,类型,ARRAY,present 来源: https://blog.csdn.net/qq_39940205/article/details/121060451