pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vangelis-Maria Tougia <tougias@cytanet.com.cy>
To: pgsql-sql@postgresql.org
Subject: UPDATE table SET col = (SELECT ...)
Date: Wed, 25 Jun 2003 12:00:00 +0300
Message-ID: <LPBBJCOFLNPHLEKEIJJFKEMACCAA.tougias@cytanet.com.cy> (raw)

Hi,
I found follwing email sent to you in internet.
I am interested in same issue myself.
Did you finally found out any more information about how to Update a column
of a table by selecting value from another table?


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: <LPBBJCOFLNPHLEKEIJJFKEMACCAA.tougias@cytanet.com.cy>
Permalink:  ../LPBBJCOFLNPHLEKEIJJFKEMACCAA.tougias@cytanet.com.cy/
Also on:    postgresql.org/message-id/LPBBJCOFLNPHLEKEIJJFKEMACCAA.tougias@cytanet.com.cy

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: tougias@cytanet.com.cy
  Subject: Re: UPDATE table SET col = (SELECT ...)
  In-Reply-To: <LPBBJCOFLNPHLEKEIJJFKEMACCAA.tougias@cytanet.com.cy>
  References: <LPBBJCOFLNPHLEKEIJJFKEMACCAA.tougias@cytanet.com.cy>

* 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