insert into / select from / serial problem

From: "tgh002" <arnulfh(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: insert into / select from / serial problem
Date: 2005-08-10 03:03:47
Message-ID: 1123643026.939110.310310@g47g2000cwa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I am using a insert statement like:

INSERT INTO newtable
SELECT field1, field2 FROM anothertable

newtable structure is: serial, varchar, varchar

What syntax do I use to insert the serial field? Ive tried something
like:
INSERT INTO newtable
SELECT nextval('newtable_id_seq'), field1, field2 FROM anothertable
but that doesnt work

Any ideas? Greatly appreciated!

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-08-10 03:29:13 Re: **SPAM** Faster count(*)?
Previous Message Tom Lane 2005-08-10 02:49:14 Re: **SPAM** Faster count(*)?