pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: Pierre Couderc <pierre@couderc.eu>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: how to write correctly this update ?
Date: Wed, 22 May 2019 07:19:28 -0600
Message-ID: <7D3837A3-CFEC-4D65-AC70-12193C1124D2@gmail.com> (raw)
In-Reply-To: <388af3c8-bfcf-8e38-4634-7ebda366f410@couderc.eu>
References: <388af3c8-bfcf-8e38-4634-7ebda366f410@couderc.eu>

Don’t use the alias on the column(s) being set.
This passed the parser:
UPDATE  personnes T1 SET nom_naiss=T1.nom FROM  personnes T2, personnes T3
WHERE T1.id=T2.id_mere AND T2.id_pere=T3.id AND T1.nom != T3.nom;

(I have no data in my table so I can’t confirm the logic.  You seem to want to update mother’s maiden name if her current (sur)name doesn’t match that of the father of (one of?) her children?  That might be a serious leap of faith.)

> On May 22, 2019, at 6:43 AM, Pierre Couderc <pierre@couderc.eu> wrote:
> 
> I have tried many ways to update a table  :
> 
> UPDATE  personnes T1 SET T1.nom_naiss=T1.nom FROM  personnes T2, personnes T3
> WHERE  ....;
> 
> 
> UPDATE  personnes T1 SET T1.nom_naiss=T1.nom FROM  personnes T1, personnes T2, personnes T3
> WHERE ..;
> 
> 
> In my case , where clause is : WHERE T1.id=T2.id_mere AND T2.id_pere=T3.id AND T1.nom != T3.nom;
> 
> Thanks.
> 
> PC
> 
> 
> 
> 
> 
> 






view thread (3+ messages)  latest in thread

Message-ID: <7D3837A3-CFEC-4D65-AC70-12193C1124D2@gmail.com>
Permalink:  ../7D3837A3-CFEC-4D65-AC70-12193C1124D2@gmail.com/
Also on:    postgresql.org/message-id/7D3837A3-CFEC-4D65-AC70-12193C1124D2@gmail.com

 · 

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-general@postgresql.org
  Cc: robjsargent@gmail.com, pierre@couderc.eu
  Subject: Re: how to write correctly this update ?
  In-Reply-To: <7D3837A3-CFEC-4D65-AC70-12193C1124D2@gmail.com>
  References: <388af3c8-bfcf-8e38-4634-7ebda366f410@couderc.eu> <7D3837A3-CFEC-4D65-AC70-12193C1124D2@gmail.com>

* 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