MySQL JSON 查询结果去掉双引号

| 选择喜欢的代码风格  

默认用 JSON_EXTRACT 会有双引号 "


mysql> SELECT JSON_EXTRACT(fld_Json, '$[0][1]') FROM tab_xxx;

+-----------------------------------------------------+
| "CommandNotFound"                                   |
+-----------------------------------------------------+

方法 1:通过使用 ->> 直接取


mysql> SELECT fld_Json->>'$[0][1]' FROM tab_xxx;

+---------------------------------------------------+
| CommandNotFound                                   |
+---------------------------------------------------+

方法 2:用 JSON_UNQUOTE


mysql> SELECT JSON_UNQUOTE(JSON_EXTRACT(fld_Json, '$[0][1]')) FROM tab_xxx;

+---------------------------------------------------+
| CommandNotFound                                   |
+---------------------------------------------------+

MySQL JSON 扩展阅读:




发表评论