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 1gUvEd-0003PT-8m for pgsql-general@arkaria.postgresql.org; Thu, 06 Dec 2018 15:06:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUvEb-0002GD-MZ for pgsql-general@arkaria.postgresql.org; Thu, 06 Dec 2018 15:06:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUvEb-0002G6-En for pgsql-general@lists.postgresql.org; Thu, 06 Dec 2018 15:06:37 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUvEU-00019Y-RW for pgsql-general@postgresql.org; Thu, 06 Dec 2018 15:06:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wB6F6OF5013387; Thu, 6 Dec 2018 10:06:24 -0500 From: Tom Lane To: Andreas Schmid cc: pgsql-general Subject: Re: UNION ALL: Apparently based on column order rather than on column name or alias In-reply-to: References: Comments: In-reply-to Andreas Schmid message dated "Thu, 06 Dec 2018 15:48:02 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13385.1544108784.1@sss.pgh.pa.us> Date: Thu, 06 Dec 2018 10:06:24 -0500 Message-ID: <13386.1544108784@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andreas Schmid writes: > So my conclusion is that the result of UNION ALL depends on the column > order, not on the column names or aliases. Is this the intended > behaviour? Yes, this is required by SQL spec. Matching by column name would be used if you wrote a CORRESPONDING clause, but we don't implement that feature. regards, tom lane