Re: [SQL] insert into / select from / serial problem

2005-08-15 Thread PFC
On Wed, 10 Aug 2005 05:03:47 +0200, tgh002 <[EMAIL PROTECTED]> 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:

Re: [SQL] insert into / select from / serial problem

2005-08-14 Thread Tom Lane
"tgh002" <[EMAIL PROTECTED]> 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

[SQL] insert into / select from / serial problem

2005-08-14 Thread tgh002
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 FRO

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Monday 11 August 2003 03:21, Silke Trissl wrote: > > Is there something like > > INSERT INTO test_table (int_id, cust_id, cust_name) '1', SELECT id, > name from CUSTOMER: > > and if so, what ist the correct statement? If not, what is an > alternativ

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Christopher Browne
Centuries ago, Nostradamus foresaw when [EMAIL PROTECTED] (Silke Trissl) would write: > I would like to insert into a table values from a table and user > defined ones. Here is the example: > > I found this statement to insert values from another table: > > INSERT INTO test_table (cust_id, cust_nam

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Vernon Smith
Coincidentally, I have a very similar case using some twists. The table I want to insert data is something like table A ( user01 int, user02 int, ... primary key (user01, user02), CHECK ( user01 < user02 ) ); And the user table is: tabe user_table ( user int constraint pk_user primary key UNIQ

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Christoph Haller
> > Coincidentally, I have a very similar case using some twists. > > The table I want to insert data is something like > > table A ( > user01 int, > user02 int, > ... > primary key (user01, user02), > CHECK ( user01 < user02 ) > ); > > And the user table is: > > tabe user_table ( > user int constr

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Vernon Smith
Thanks, Christoph for your thought. An alternative solution I have is to fetch the user table first and act according with the retured value. It doesn't seem to have a single query solution. v. -- - Original Message - DATE: Wed, 13 Aug 2003 13:40:53 From: Christoph Haller <[EM

[SQL] INSERT INTO ... SELECT

2003-08-14 Thread Silke Trissl
Hi, I would like to insert into a table values from a table and user defined ones. Here is the example: I found this statement to insert values from another table: INSERT INTO test_table (cust_id, cust_name) SELECT id, name from CUSTOMER; But the test_table has another column, which should hav