INSERT WITH SELECT help

From: Richard Smith <ozric(at)tampabay(dot)rr(dot)com>
To: PGSQL list <pgsql-general(at)hub(dot)org>
Subject: INSERT WITH SELECT help
Date: 2000-05-21 17:56:49
Message-ID: 39282361.80F80711@tampabay.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am new to SQL so bare with me here.

I have set up a contact database. The PRIMANY KEY is person.per_id
All the other tables REFERENCE the person.per_id key. Now I want to be
able
to INSERT INTO the address table based on person.per_id by name without
having to know the value of person.per_id. Something like, I know this
does not work
but you will get the idea of what I need.

INSERT INTO address
(per_id,street,city,state,zip)
VALUES ('('SELECT per_id FROM person WHERE first ='somename')','200 some
street',
'Tampa','FL','33654');

Can somthing like this be done ? Any help would be great.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-05-21 17:59:59 Re: crash on \copy
Previous Message Bruce Momjian 2000-05-21 17:49:45 Re: [HACKERS] Re: MySQL crashme test and PostgreSQL