Subquery in INSERT? - Mailing list pgsql-novice

From Wilfred Benson
Subject Subquery in INSERT?
Date
Msg-id BAY114-F7E5FF38E0FC5E39A79AA1A70E0@phx.gbl
Whole thread Raw
Responses Re: Subquery in INSERT?  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: Subquery in INSERT?  (Shane Ambler <pgsql@007Marketing.com>)
Re: Subquery in INSERT?  (Richard Broersma Jr <rabroersma@yahoo.com>)
List pgsql-novice
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.

Thanks a lot.

-Wilf.


P.S. Sorry if I posted this twice.

_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces

http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us


pgsql-novice by date:

Previous
From: Sean Davis
Date:
Subject: could not write to hash-join temporary file: No space left on device
Next
From: "A. Kretschmer"
Date:
Subject: Re: Subquery in INSERT?