(编辑:jimmy 日期: 2025/11/6 浏览:2)
在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
}
}
}')
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接