How to do this in SQL? - Mailing list pgsql-general

From Chris Bitmead
Subject How to do this in SQL?
Date
Msg-id 3700E388.3E3A77E1@bigfoot.com
Whole thread Raw
Responses Re: [GENERAL] How to do this in SQL?
List pgsql-general
Let's say I had a table...
CREATE TABLE book (
   author oid,
   name text );
and...
CREATE TABLE author (
   name text );

and I wanted to create a book pointing to author with name 'Tolstoy'. I
want to do something like...

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

but this doesn't work. What is the correct syntax?

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

pgsql-general by date:

Previous
From: Statistical Solutions
Date:
Subject: Re: [GENERAL] Performance
Next
From: Stuart Rison
Date:
Subject: Re: [GENERAL] How to do this in SQL?