0

In PostgreSQL, my column type is json , the data is json array like:

[{"attsId": "42a2ce04-52ab-4a3c-8dfb-98c3d14b307d", "planId": 46, "filePath": "fileOperate\\upload", "cfileName": "潜在客户名单 (1).xls", "ufileName": "42a2ce04-52ab-4a3c-8dfb-98c3d14b307d.xls"}, {"attsId": "1adb2f13-00b0-4780-ae76-7a068dc3289c", "planId": 46, "filePath": "fileOperate\\upload", "cfileName": "潜在客户名单.xls", "ufileName": "1adb2f13-00b0-4780-ae76-7a068dc3289c.xls"}, {"attsid": "452f6c62-28df-47c7-8c30-038339f7b223", "planid": 48.0, "filepath": "fileoperate\\upload", "cfilename": "技术市场印花税.xls", "ufilename": "452f6c62-28df-47c7-8c30-038339f7b223.xls"}]

I want update one of the array data by element key like:

UPDATE plan_base 
    set atts->.. = {"planId":47,"name":"qm"} 
where atts->"planId"= 46 and id=2;

and someone has beterr way to do it

Meng Qian
  • 97
  • 1
  • 1
  • 9
  • 2
    How is this different to your previous question? http://stackoverflow.com/q/28296085/330315 –  Feb 09 '15 at 09:34
  • @a_horse_with_no_name the first one is update by index, and this one is update by the json key – Meng Qian Feb 09 '15 at 11:43

0 Answers0