Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTRAe-0000dw-HG for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 13:20:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hTR9e-0001iC-8o for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 13:19:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTR9d-0001hS-SB for pgsql-general@lists.postgresql.org; Wed, 22 May 2019 13:19:38 +0000 Received: from mail-it1-x12e.google.com ([2607:f8b0:4864:20::12e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTR9W-0005zr-TI for pgsql-general@lists.postgresql.org; Wed, 22 May 2019 13:19:36 +0000 Received: by mail-it1-x12e.google.com with SMTP id i63so2985977ita.3 for ; Wed, 22 May 2019 06:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=q7E9OsemQkttVzFbyjEq8lIPeNj92E+3+lNrFUl4530=; b=NAdWH1NkzJxGAfxFgDEKgNH2l5lJex5jF+QmK/i1mM08tumj2TCkamm9f/UVzr/MA9 CHiZ+kfs89jU0cjrZLZvETwNnSfva8aFrCwz0d3PBXFaLQOmgMZVwZ3zBtt/wUxe/5Jh A6j+FUVwCx3q8po7xUqmGrAXS+M7E56h5KdHyl+89HZDu8upsAzhSMU6pPvGstOlZ/iH OAa4foFrm8y/iObIQ3wobcu4KRbHX7ufqwod5uRgkiY2ZX4nH2UU9yT5Gx86MRT5OHVb ebirSGfcToXoGt0xliq8kE5Tu+iG8OklG5TVsgNxUTWNTaGalV7wHTwwSEnIA6Zx9O9S hJNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=q7E9OsemQkttVzFbyjEq8lIPeNj92E+3+lNrFUl4530=; b=DOJxzRJV7WVpP6mU83Tj116Vd3dCa1t5LLlt+VBcJZ8lY0//bNNikwGt1eRhjvzRKV nUKEhfFd4JcfJh9lg4sk2BMHihOj1kYyIbrxoB45i5m7KhTQeFfK1uD8FALc0vemhAZr /uGlLDi9YdOgnAkJADX5ipqzlBxgSpTY7bWQfkdhTSG6M3AO8f+oyt2gAcg5qjoMJ6zr JYxjVQmLD0PVzXhkVVSWTeWCl9FZDp9a9USbCcfndavd2xVScXSZY2yQR/ZeuCYQ5Ggm LNV5e0ioMBRE8Fp9XcK0ez0oikuvu4EPzW/L6abpwh2MMIoInn+0gDhvR0lGde1lXyGQ Bfzw== X-Gm-Message-State: APjAAAX/WrDpy2mTjnaSTtUQa3q990I2IUx318f8S110klFrDnxXuY5s wtAO5lxWzT+pxYz4FNfAT8ADXcohjU8= X-Google-Smtp-Source: APXvYqwHULUzl5qXAZ8HEFUjOhccj6JAqjuh39xpN1DMstRFjEOGTZzVs43vd3ylbF69FVCEZZ6ROg== X-Received: by 2002:a24:684b:: with SMTP id v72mr7867312itb.174.1558531170190; Wed, 22 May 2019 06:19:30 -0700 (PDT) Received: from [192.168.1.108] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id m189sm2851029itm.21.2019.05.22.06.19.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 06:19:29 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: how to write correctly this update ? From: Rob Sargent In-Reply-To: <388af3c8-bfcf-8e38-4634-7ebda366f410@couderc.eu> Date: Wed, 22 May 2019 07:19:28 -0600 Cc: "pgsql-generallists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: <7D3837A3-CFEC-4D65-AC70-12193C1124D2@gmail.com> References: <388af3c8-bfcf-8e38-4634-7ebda366f410@couderc.eu> To: Pierre Couderc X-Mailer: Apple Mail (2.3445.102.3) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Don=E2=80=99t use the alias on the column(s) being set. This passed the parser: UPDATE personnes T1 SET nom_naiss=3DT1.nom FROM personnes T2, = personnes T3 WHERE T1.id=3DT2.id_mere AND T2.id_pere=3DT3.id AND T1.nom !=3D T3.nom; (I have no data in my table so I can=E2=80=99t confirm the logic. You = seem to want to update mother=E2=80=99s maiden name if her current = (sur)name doesn=E2=80=99t 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 wrote: >=20 > I have tried many ways to update a table : >=20 > UPDATE personnes T1 SET T1.nom_naiss=3DT1.nom FROM personnes T2, = personnes T3 > WHERE ....; >=20 >=20 > UPDATE personnes T1 SET T1.nom_naiss=3DT1.nom FROM personnes T1, = personnes T2, personnes T3 > WHERE ..; >=20 >=20 > In my case , where clause is : WHERE T1.id=3DT2.id_mere AND = T2.id_pere=3DT3.id AND T1.nom !=3D T3.nom; >=20 > Thanks. >=20 > PC >=20 >=20 >=20 >=20 >=20 >=20