Re: [SQL] INSERT and SELECT - Mailing list pgsql-sql

From Eric BARROCA
Subject Re: [SQL] INSERT and SELECT
Date
Msg-id 87emcuu4f4.fsf@venus.fondation
Whole thread Raw
In response to Re: [SQL] INSERT and SELECT  (Stuart Rison <rison@biochemistry.ucl.ac.uk>)
Responses Re: [SQL] INSERT and SELECT
List pgsql-sql
Stuart Rison <rison@biochemistry.ucl.ac.uk> writes:
> INSERT INTO table VALUES SELECT oid, 'test' FROM membre WHERE
> email="toto@toto.com";
I've tried it, but it doesn't work too ("paser error near or at select"),
even if I replace " by '.

The sample table "table" :- ID int4- login varchar()- password varchar()

I'd like to put into the ID culumn the result of (SELECT ...), into the
login column "test" and into the password one "testpass".

I've tried many queries like :

INSERT INTO table (id, login, password) VALUES SELECT oid, 'test',
'testpass' FROM membre WHERE email='toto@toto.com';

or

INSERT INTO table (id, login, password) VALUES ((SELECT oid FROM membre
WHERE email='toto@toto.com'), 'test', 'testpass'); 

or 

INSERT INTO table (id, login, password) VALUES (SELECT oid, 'test',
'testpass' FROM membre WHERE email='toto@toto.com');

...

But nothing give me a result. I get always parse error near select, and I
can't figure why.


Best Regards,

Éric.


pgsql-sql by date:

Previous
From: Vladimir Terziev
Date:
Subject: Re: [SQL] INSERT and SELECT
Next
From: "Nikolay Mijaylov"
Date:
Subject: Re: [SQL] INSERT and SELECT