对mysql数据库的处理
userBelong字段存储json格式[1,2,3]
SELECT JSON_SEARCH(userBelong,'one',3) FROM table_name始终为空
SELECT JSON_SEARCH(userBelong,'one',3) FROM table_name
查阅资料后发现,json_search找不到整数类型
也就是说字段存储格式为整数的话,此方法搜索无效
UPDATE presaleshop
SET userBelong = JSON_REMOVE( userBelong, REPLACE ( json_search( userBelong, 'one', 1 ), '"', '' ) )
WHERE
json_search(userBelong, 'one', 1 ) IS NOT NULL and id = 14
更新也无效,白费好久时间0.0
ps:增加userBelong字段sql
UPDATE presaleshop SET userBelong = CONCAT(left(userBelong , LENGTH(UserBelong)-1),',',%s,']') WHERE id = %s"%(add_userid,add_shopid)