mysql 5.7 json類型字段操作

json裏某個字段更新

update service_cloud SET 
  host_info = JSON_SET( host_info, '$.bandwidth',2)  
WHERE  service_code = 'PPP01468648212820';

以json裏某個字段爲查詢條件進行查詢

select host_info from service_cloud  
where JSON_EXTRACT(host_info, "$.roomId") = 'HB'

也可以寫成另一種格式

select host_info from service_cloud
where host_info->"$.roomId"  = 'HB'


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