X-Received: by 10.55.156.140 with SMTP id f134mr14317429qke.31.1520351223966; Tue, 06 Mar 2018 07:47:03 -0800 (PST) X-Received: by 10.31.67.71 with SMTP id q68mr2120207vka.9.1520351223671; Tue, 06 Mar 2018 07:47:03 -0800 (PST) Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!t24no4488968qtn.0!news-out.google.com!m4ni1318qte.0!nntp.google.com!r16no4459689qtn.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.databases.postgresql Date: Tue, 6 Mar 2018 07:47:03 -0800 (PST) In-Reply-To: <23a909c9-9a4e-462a-89fa-a1efda4fb198@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=5.238.208.244; posting-account=AVfdWQoAAAB6NsIEvw9Dr_Zj2mt265Gj NNTP-Posting-Host: 5.238.208.244 References: <23a909c9-9a4e-462a-89fa-a1efda4fb198@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Update Json column From: forough m Injection-Date: Tue, 06 Mar 2018 15:47:03 +0000 Content-Type: text/plain; charset="UTF-8" Lines: 20 Xref: csiph.com comp.databases.postgresql:813 On Monday, March 5, 2018 at 1:14:54 PM UTC+3:30, forough m wrote: > On Thursday, March 1, 2018 at 1:48:05 PM UTC+3:30, Laurenz Albe wrote: > > forough m wrote: > > > > >>> I create a table with a Json type column. I need to update one > > >>> key:value in Json. i.e increment value of 3 to 5. Can i do it? > > >> > > >> If you have PostgreSQL 9.5 or better, you can use "json_set" like this: > > >> > > >> [...] > > >> > > > Sorry. I test it but it has no result. SQL query executed without any > > > error but value in Json not changed. > > > > Then you must be doing something wrong. > > Hard to say what if you don't show your query. > > Worked. Thanks :) But, why it remove all fields if {b,c} not exist? > I want to insert it if not exist I want to say: If 'f' exist, then increment it +3 else, if not exist create it with value = 0