Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLRxW-0002Mw-G1 for pgsql-general@arkaria.postgresql.org; Wed, 23 May 2018 11:29:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fLRxV-0002w1-9f for pgsql-general@arkaria.postgresql.org; Wed, 23 May 2018 11:29:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLRxU-0002vr-UY for pgsql-general@lists.postgresql.org; Wed, 23 May 2018 11:29:33 +0000 Received: from aragorn.net-wizard.org ([138.201.127.29] helo=gandalf.net-wizard.org) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLRxR-00071s-JQ for pgsql-general@postgresql.org; Wed, 23 May 2018 11:29:31 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.net-wizard.org (Postfix) with ESMTP id D781780898; Wed, 23 May 2018 13:29:25 +0200 (CEST) X-Virus-Scanned: Gentoo amavisd-new at aragorn Received: from aragorn.net-wizard.org ([127.0.0.1]) by localhost (aragorn.net-wizard.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Qiw66iTCBNnS; Wed, 23 May 2018 13:29:23 +0200 (CEST) Received: from MTEC0211 (mtec-lee-dock-2-133.ethz.ch [129.132.6.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: clavadetscher@swisspug.org) by gandalf.net-wizard.org (Postfix) with ESMTPSA id 31F2D80892; Wed, 23 May 2018 13:29:19 +0200 (CEST) From: "Charles Clavadetscher" To: "'a'" <372660931@qq.com>, "'pgsql-general'" References: In-Reply-To: Subject: RE: How do I select composite array element that satisfy specific conditions. Date: Wed, 23 May 2018 13:29:12 +0200 Message-ID: <069101d3f289$4c5c38f0$e514aad0$@swisspug.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQJ1QK3OvwXexOVyXz86EOLOXtkYiKL6j43g Content-Language: de-ch List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi > -----Original Message----- > From: a [mailto:372660931@qq.com] > Sent: Mittwoch, 23. Mai 2018 11:43 > To: pgsql-general > Subject: How do I select composite array element that satisfy specific conditions. > > Hi, say if I have composite type and table > > create type A as( > x float8, > y float8 > ); > > create table B( > Ay A[] > ); > > insert into B > values(array[ > (1,2)::A, > (3,4)::A] > ); > > How could I select the element of Ay that satisfy x=3?? > > Thank you so much!! > > Shore I did not really follow this thread, so I am not in clear, why you want to complicate your life that much. You create a custom data type and then use it in an array in a column. A complex hierarchical structure. Why don't you simply use JSON or JSONB? Your example sounds terribly academic very much like a school assignment. Bye Charles