在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 } }}')
總結
以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對VeVb武林網的支持。
新聞熱點
疑難解答