Re: [GENERAL] How to do this in SQL? - Mailing list pgsql-sql

From Chris Bitmead
Subject Re: [GENERAL] How to do this in SQL?
Date
Msg-id 3700E7C9.FCD0D4C5@bigfoot.com
Whole thread Raw
In response to Re: [GENERAL] How to do this in SQL?  (Herouth Maoz <herouth@oumail.openu.ac.il>)
Responses Re: [GENERAL] How to do this in SQL?  (Herouth Maoz <herouth@oumail.openu.ac.il>)
List pgsql-sql
Herouth Maoz wrote:

> INSERT INTO BOOK (name, author)
> SELECT 'War and Peace', oid
> FROM author
> WHERE name = 'Tolstoy';

Thanks! Now what if I had...
CREATE TABLE book (author oid, publisher oid);

What is the syntax? Is it...

INSERT INTO BOOK(author, publisher)
SELECT author.oid, publisher.oid 
FROM author, publisher
WHERE author.name = 'Tolstoy' AND publisher.name = 'Penguin';

Is that right?


-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com


pgsql-sql by date:

Previous
From: Herouth Maoz
Date:
Subject: Re: [GENERAL] How to do this in SQL?
Next
From: Herouth Maoz
Date:
Subject: Re: [GENERAL] How to do this in SQL?