Received: from tech.com.au (IDENT:root@techpt.lnk.telstra.net [139.130.75.122]) by hub.org (8.9.2/8.9.1) with ESMTP id JAA46613 for ; Tue, 30 Mar 1999 09:46:33 -0500 (EST) (envelope-from chris.bitmead@bigfoot.com) Received: from bigfoot.com (chris@localhost [127.0.0.1]) by tech.com.au (8.8.7/8.8.7) with ESMTP id AAA11652 for ; Wed, 31 Mar 1999 00:45:29 +1000 Sender: chris@tech.com.au Message-ID: <3700E388.3E3A77E1@bigfoot.com> Date: Tue, 30 Mar 1999 14:45:28 +0000 From: Chris Bitmead X-Mailer: Mozilla 4.51 [en] (X11; I; Linux 2.0.36 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: How to do this in SQL? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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