时间:2021-01-02 15:14:22 | 栏目:Mysql | 点击:次
在MySQL5.7.8之后开始支持一种可高效获取JSON文本中数据的原生JSON类型,该类型具有以下优点:
另外,系统对JSON格式做了一些限制:
在插入json数据的时候遇到的问题
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘{
插入代码
insert into `players` (`id`,`player_and_games`) values(1,{ "id":1, "name":"aaa", "games_played":{ "Battlefiedld":{ "weapon":"adsf", "level":20 }, "Crazy":{ "weapon":"adsf", "level":20 } } })
存在问题,json没有用引号,正确的方式如下
insert into `players` (`id`,`player_and_games`) values(1,'{ "id":1, "name":"aaa", "games_played":{ "Battlefiedld":{ "weapon":"adsf", "level":20 }, "Crazy":{ "weapon":"adsf", "level":20 } } }')
总结