Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1luCib-0003HX-E1 for pgsql-general@arkaria.postgresql.org; Fri, 18 Jun 2021 11:31:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1luCia-0004tJ-CY for pgsql-general@arkaria.postgresql.org; Fri, 18 Jun 2021 11:31:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1luCia-0004tB-3s for pgsql-general@lists.postgresql.org; Fri, 18 Jun 2021 11:31:24 +0000 Received: from mout.kundenserver.de ([212.227.17.13]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1luCiY-0005xp-68 for pgsql-general@lists.postgresql.org; Fri, 18 Jun 2021 11:31:23 +0000 Received: from [192.168.0.151] ([79.221.75.223]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N2EHo-1l9QjG3k9W-013dYV for ; Fri, 18 Jun 2021 13:31:20 +0200 Subject: Re: short sql question To: pgsql-general@lists.postgresql.org References: From: "Georg H." Message-ID: <36242505-b312-d4ec-3331-fac467d1ddf4@silentrunner.de> Date: Fri, 18 Jun 2021 13:31:19 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------C0323A0BF2BDB7A5B4618FD2" Content-Language: de-DE X-Provags-ID: V03:K1:y03rkD4QMKq6K7cEL9laYnHhsYJhaeoX4C8k5JK2nYT6A34FM/Q StAPGKaX+dZAyWHOmbaGFucnVCtEQRMtQTtRZMH5kuiVYTJCqdTipkSsDNzzdryVSz0KuD5 gvnEp851ynEAbd2UEfTbuKMO4rf8QydPxbvCxW6N91TSDmDGXZKWVrXRW/lX587M8fjbo8K AdzvfsK3rTUJTy6cF6gsA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:aAj6AE8/YjE=:08k7bgMp/HMLd2gvCkPe5c cuubW+jbATCTkMYNNrVsZtTsz1b4L0+qco/s9MdgP6VUIWIMj1p33H2b5/cYDRhTnpp6ZWrog Ata5z/omEQDKUDdqxFv66TLNT54kkTI+wUtkP8JDkhg/GhDIabDlpsNwlI9YebGLpTRKrb/uM sh4unZ/WEmM+xNxR7HPjcOgZouOQOawVU5gjf/wJLorZeV5oBWonxytZTs7HK+HodnqXC9vn/ WZqiqhXTYK5QwvEYdH9vpnD4Q/f7KDnm7JBRLZYqvJLcP0aRd9JpzvFSQlE5ab+cvRJ9sjgvj 5WdQygjhpi1HHfu5+z520ChHTYUmQFVBJfDcXY2z+Rp22c2eHDD9Q0t5uIdK7LJi5BHnTuS0f xVYHxFS5Qguz9b1qp2v4FB7tl5j2yVdPdxVBvhRQ1iWz/kd7Fo/nmQHH6iLOWx+wRdrxUnbDl bKwCIUdGvmdE4bgjJLBN+yQCL9PfyZyxaGj5wk/wQcuBPJle90hXHBZxSbwFMuMMvSxBSu0OE nLW+LQOtu01wXSp4Ocqe4o= List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------C0323A0BF2BDB7A5B4618FD2 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Am 18.06.2021 um 09:15 schrieb goldgraeber-werbetechnik@t-online.de: > Hi, > > I just cannot see what is wrong with my query: > > create table files (id int, name text, prev_name text, ....); > create table fnchanged (id int, name text); > > update files f set prev_name = f.name, name = c.name from fnchanges c where f.id = c.id and c.name != f.name your update statement works for me after changing from fnchanges   to from fnchanged (as written in your create statement) but I've gotERROR: relation "fnchanges" does not exist instead of a syntax error > > --- gets syntax error at "from" > > (Using PostgreSQL 10.4 on a NAS box) > > Best regards > Wolfgang > kind regards Georg --------------C0323A0BF2BDB7A5B4618FD2 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi,

Am 18.06.2021 um 09:15 schrieb goldgraeber-werbetechnik@t-online.de:
Hi,

I just cannot see what is wrong with my query:

create table files (id int, name text, prev_name text, ....);
create table fnchanged (id int, name text);

update files f set prev_name = f.name, name = c.name from fnchanges c where f.id = c.id and c.name != f.name

your update statement works for me after changing

from fnchanges

  to

from fnchanged 
(as written in your create statement) but I've got ERROR:  relation "fnchanges" does not exist 
instead of a syntax error

--- gets syntax error at "from"

(Using PostgreSQL 10.4 on a NAS box)

Best regards
Wolfgang

kind regards
Georg

--------------C0323A0BF2BDB7A5B4618FD2--