pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Eric Marsden <emarsden@mail.dotcom.fr>
To: pgsql-sql@postgresql.org
Subject: UPDATE table SET col = (SELECT ...)
Date: 30 Dec 1998 18:01:28 +0100
Message-ID: <wzi4sqdzhqv.fsf@mail.dotcom.fr> (raw)

Hello,

If I understand the SQL references I have read, UPDATEs are allowed to
pull data from SELECT statements, something like

  UPDATE table SET col1 = (SELECT val1 FROM table WHERE id = 34),
               SET col2 = (SELECT val2 FROM table WHERE id = 34)
         WHERE id = 35;

However, the PostgreSQL parser chokes on the 'SELECT'. The
documentation says

  UPDATE table SET column = expression [, ...]
      [ FROM fromlist ]
      [ WHERE condition ]         

  expression = A valid expression or value to assign to column.


I don't know exactly how to interpret `valid expression'.
      
-- 
Eric Marsden
emarsden @ mail.dotcom.fr
It's elephants all the way down



view thread (3+ messages)  latest in thread

Message-ID: <wzi4sqdzhqv.fsf@mail.dotcom.fr>
Permalink:  ../wzi4sqdzhqv.fsf@mail.dotcom.fr/
Also on:    postgresql.org/message-id/wzi4sqdzhqv.fsf@mail.dotcom.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: emarsden@mail.dotcom.fr
  Subject: Re: UPDATE table SET col = (SELECT ...)
  In-Reply-To: <wzi4sqdzhqv.fsf@mail.dotcom.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox