How to do this in SQL?

From: Chris Bitmead <chris(dot)bitmead(at)bigfoot(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: How to do this in SQL?
Date: 1999-03-30 14:45:28
Message-ID: 3700E388.3E3A77E1@bigfoot.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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(dot)bitmead(at)bigfoot(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kollar Lajos 1999-03-30 14:49:08 Re: [GENERAL] sorting by date & time in descending order ??
Previous Message Statistical Solutions 1999-03-30 14:23:39 Re: [GENERAL] Performance

Browse pgsql-sql by date

  From Date Subject
Next Message Kollar Lajos 1999-03-30 14:49:08 Re: [GENERAL] sorting by date & time in descending order ??
Previous Message Herouth Maoz 1999-03-30 14:00:01 Re: [GENERAL] sorting by date & time in descending order ??