postgresql 递归使用json_set 函数来设置非最外层key对应value的值

-- select id,button_setting::JSON -> 'pc' -> 'location'  from chat_web



select id,(button_setting -> 'pc')::JSONB -> 'location'  
from chat_web 
where ((button_setting -> 'pc')::JSONB -> 'location')::text::int = 5

update  chat_web
set button_setting = jsonb_set (button_setting, '{pc}' , jsonb_set( (button_setting -> 'pc')::jsonb , '{location}', '3' , false)::jsonb ,false )
where id = 153

select *
from chat_web
where id = 153

你可能感兴趣的:(SQL)