Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-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

pgsql-sql by date

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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group