pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: s-fery@kkt.sote.hu
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] select in update
Date: Tue, 24 Nov 1998 10:47:23 +0200
Message-ID: <l03110700b28020eb5be7@[147.233.159.109]> (raw)
In-Reply-To: <Pine.LNX.3.96.981124003803.1032D-100000@Pons.sote.hu>

At 1:41 +0200 on 24/11/98, Engard Ferenc wrote:


> Yet another question: (quite busy today... :)
>
> oeptest=> update shorttest2 set b=(select b from shorttest t1 where
>t1.a=1) where a=2;
> ERROR:  parser: parse error at or near "select"
>
> It means that the subquery in update is not implemented? And if it isn't,
> how can I evade it? Maybe select ... into .., but it's not a good idea in a
> big table... :(((
>
> Any help?

The long-standing syntax for this in PostgreSQL is:

UPDATE shorttest2
SET b=t1.b
FROM shorttest t1
WHERE t1.a=1;

Please, look up the manpages for the command you want to invoke, or \h it.
You may discover syntax options that cover what you need. I have PostgreSQL
6.2.1, and running "\h update" in psql yields:

testing=> \h update
Command: update
Description: update tuples
Syntax:
update <class_name> set <attr1>=<expr1>,...<attrN>=<exprN> [from <from_clause>]
[where <qual>];

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (4+ messages)  latest in thread

Message-ID: <l03110700b28020eb5be7@[147.233.159.109]>
Permalink:  ../l03110700b28020eb5be7@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03110700b28020eb5be7@[147.233.159.109]

 · 

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: herouth@oumail.openu.ac.il, s-fery@kkt.sote.hu
  Subject: Re: [SQL] select in update
  In-Reply-To: <l03110700b28020eb5be7@[147.233.159.109]>
  References: <Pine.LNX.3.96.981124003803.1032D-100000@Pons.sote.hu> <l03110700b28020eb5be7@[147.233.159.109]>

* 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