Re: Subquery in INSERT? - Mailing list pgsql-novice

From Wilfred Benson
Subject Re: Subquery in INSERT?
Date
Msg-id BAY114-F3C711C54620268AE1A229A70F0@phx.gbl
Whole thread Raw
In response to Re: Subquery in INSERT?  (Richard Broersma Jr <rabroersma@yahoo.com>)
List pgsql-novice
Thanks a lot, guys. I wanted to know if it was possible. Thanks for setting
me on the right path.

-Wilf.



> > What I'm trying to do is copy a value from one column to another in the
>same
> > table. The table looks like this:
> >
> >   first | second
> > ---------------------
> > 1      |
> > 2      |
> > 3      |
> > 4      |
> > ...
> >
> > It's named 'copier'.
> >
> > The first column is sequence-generated, and the second has yet to have
> > anything loaded (at this stage it's only a test table). So what I'm
>trying
> > to do is quick copy of '1' from 'first' to 'second' with this query:
> >
> > INSERT INTO copier VALUES(nextval('sequence'), ((SELECT first FROM
>copier
> > WHERE copier.first=1) AS second));
> >
> > ...and I'm getting this error:
> > ERROR: syntax error at or near "AS" at character 93
> >
> > So what I want to know is, is it possible? If it is and my query is
> > incorrect and anyone can tell me what's wrong with it that would be
>great.

_________________________________________________________________
Get FREE company branded e-mail accounts and business Web site from
Microsoft Office Live
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/


pgsql-novice by date:

Previous
From: "Brandon Aiken"
Date:
Subject: Re: How to Substract Milliseconds from A timestamp(3) Field
Next
From: Layton Duncan
Date:
Subject: Lookups