【删除 json 字符串 other_info 中字段 price 的描述“元/元起”】
-- 为避免误删其他字段内的“元/元起”,使用正则只处理 price 与下一个 key (nextKey)之间的数据
WITH t as(
SELECT id
,replace(other_info
, substring(other_info,'"price":.*[元|元起]","nextKey"')
, regexp_replace(substring(other_info,'"price":.*[元|元起]","nextKey"'), '[元|元起]', '')
) as new_other_info
FROM tableName
WHERE position('元' in other_info)>0
)
UPDATE tableName a
SET other_info = t.new_other_info
FROM t
WHERE a.id = t.id