Re: Possible to UPDATE array[] columns? - Mailing list pgsql-general

From Sam Mason
Subject Re: Possible to UPDATE array[] columns?
Date
Msg-id 20091030182523.GD5407@samason.me.uk
Whole thread Raw
In response to Re: Possible to UPDATE array[] columns?  (Sam Mason <sam@samason.me.uk>)
List pgsql-general
On Fri, Oct 30, 2009 at 06:23:28PM +0000, Sam Mason wrote:
> On Fri, Oct 30, 2009 at 10:47:26AM -0700, Blake Starkenburg wrote:
> > ID  | scores
> > 2   | {54,14,21,8}
> > 3   | {12,0,7}
> >
> > Now I want to append the score of 12 on row:ID 2 so the new scores would
> > read {54,14,21,8,12}.
>
> You need to use the normal array concatenation operator, ||, for
> example:
>
>   UPDATE table SET scores = scores || (
>     SELECT scores FROM table WHERE id = 12)
>   WHERE id = 2;

Doh, sorry, I was thinking you were asking for something more
complicated.  I don't seem to be doing very well here at all today!

--
  Sam  http://samason.me.uk/

pgsql-general by date:

Previous
From: Sam Mason
Date:
Subject: Re: Possible to UPDATE array[] columns?
Next
From: Thom Brown
Date:
Subject: Re: CREATE TABLE LIKE and SERIAL