pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedinsert into / select from / serial problem
3+ messages / 3 participants
[nested] [flat]
* insert into / select from / serial problem
@ 2005-08-10 03:03 tgh002 <arnulfh@gmail.com>
2005-08-15 00:33 ` Re: insert into / select from / serial problem Tom Lane <tgl@sss.pgh.pa.us>
2005-08-15 07:49 ` Re: insert into / select from / serial problem PFC <lists@boutiquenumerique.com>
0 siblings, 2 replies; 3+ messages in thread
From: tgh002 @ 2005-08-10 03:03 UTC (permalink / raw)
To: 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!
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: insert into / select from / serial problem
2005-08-10 03:03 insert into / select from / serial problem tgh002 <arnulfh@gmail.com>
@ 2005-08-15 00:33 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 3+ messages in thread
From: Tom Lane @ 2005-08-15 00:33 UTC (permalink / raw)
To: tgh002 <arnulfh@gmail.com>; +Cc: pgsql-sql
"tgh002" <arnulfh@gmail.com> writes:
> 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?
I think you want to just let it default, which you'd do with, say,
INSERT INTO newtable (fielda, fieldb)
SELECT field1, field2 FROM anothertable
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: insert into / select from / serial problem
2005-08-10 03:03 insert into / select from / serial problem tgh002 <arnulfh@gmail.com>
@ 2005-08-15 07:49 ` PFC <lists@boutiquenumerique.com>
1 sibling, 0 replies; 3+ messages in thread
From: PFC @ 2005-08-15 07:49 UTC (permalink / raw)
To: tgh002 <arnulfh@gmail.com>; pgsql-sql
On Wed, 10 Aug 2005 05:03:47 +0200, tgh002 <arnulfh@gmail.com> wrote:
> 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:
Try :
INSERT INTO newtable (col1, col2) SELECT field1, field2 FROM anothertable
col1, col2 being the names of your columns that you want to put field1 and
field2 into...
The serial will take care of itself.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-08-15 07:49 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-10 03:03 insert into / select from / serial problem tgh002 <arnulfh@gmail.com>
2005-08-15 00:33 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-08-15 07:49 ` PFC <lists@boutiquenumerique.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox