mysql查询整个json中具体某个字段的数据

最近发现mysql强大的功能,可以直接查询出整个json中具体某个值的数据:
json对应的字段内容是这样的:
msg_content对应的内容就是json字段:

{
    "fileName":"测非编1.mp4",
    "filePath":"/mnt/windows/folderscan/uploadAndTask/91/测非编1.mp4",
    "taskName":"截取首帧失败",
    "taskFailStage":"1"
}

原始数据是这样的:
在这里插入图片描述

 SELECT
	id,
	msg_code AS msgCode,
	read_flag AS readFlag,
	msg_content ->> '$.mediaId' as mediaId,
	msg_content ->> '$.fileName' as fileName,
	msg_content ->> '$.taskName' as taskName,
	msg_content ->> '$.filePath' as filePath
FROM
	notice_msg
WHERE
	receive_user_id = '79'

拆分开查询后的结果是这样:
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章