好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

mysql中json取,查,改,去双引号

id title attr 1 李白 {“banji”:“1班”,“xueduan”:“初三”,“xuexiao”:“某某一中”,“jiaoshi_id”:“11,12”}

取值:json_extract(json字段,"$.key值");

取学校:
select json_extract(attr,"$.xuexiao") xuexiao from table where id=1
结果:

xuexiao “某某二中”

去掉双引号
json_unquote()
取教师id去双引号

select json_unquote(json_extract(attr,"$.jiaoshi_id")) jaoshi_id from table where id=1
结果:

jiaoshi_id 11,12

//此处有更简便的方式未
jsondata->"$.attribute"
jsondata->>"$.attribute"

修改:
json_replace(json_字段,"$.key值",“value”);只替换;

json_set(字段,"$.shuxing",“value”);如果有替换,没有就新增

 

mysql中json取,查,改,去双引号

标签:attr   replace   set   修改   extract   hub   mys   ued   aos   

查看更多关于mysql中json取,查,改,去双引号的详细内容...

  阅读:34次