pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jürgen Cappel <email@juergen-cappel.de>
To: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Update from same table
Date: Wed, 4 Feb 2004 17:46:19 +0100
Message-ID: <JEEKIPNAKJNCFLMOBKHGOEDKDCAA.email@juergen-cappel.de> (raw)

Hello,

I want to update columns in a table that match a fixed key
from the same column of the same table matching another fixed key.
There can be several tuples per key distinguished by a secondary id.
Tuples are unique with the combined keys. Maybe a query could look
something like this:

	UPDATE a.mytable from b.mytable
	SET a.mycolumn = b.mycolumn
	WHERE a.firstid = some_key
	AND b.firstid = some_other_key
	AND a.secondaryid = b.secondaryid;

But it's a syntax error. I tried a subselect but i'm failing to connect
the subselect's 2nd ID with the update's 2nd ID.  Any help ?  Thanks,

Jürgen




view thread (2+ messages)  latest in thread

Message-ID: <JEEKIPNAKJNCFLMOBKHGOEDKDCAA.email@juergen-cappel.de>
Permalink:  ../JEEKIPNAKJNCFLMOBKHGOEDKDCAA.email@juergen-cappel.de/
Also on:    postgresql.org/message-id/JEEKIPNAKJNCFLMOBKHGOEDKDCAA.email@juergen-cappel.de

 · 

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: email@juergen-cappel.de
  Subject: Re: Update from same table
  In-Reply-To: <JEEKIPNAKJNCFLMOBKHGOEDKDCAA.email@juergen-cappel.de>

* 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