Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 364581337B4F for ; Fri, 18 Feb 2011 02:02:08 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 72876-08 for ; Fri, 18 Feb 2011 06:02:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs73.luxsci.com (rs73.luxsci.com [64.49.254.135]) by mail.postgresql.org (Postfix) with ESMTP id 88BFA1337B4A for ; Fri, 18 Feb 2011 02:02:00 -0400 (AST) Received: from GNANAM ([180.151.61.10]) (authenticated bits=0) by rs73.luxsci.com (8.13.8/8.13.8) with ESMTP id p1I61uh8031620; Fri, 18 Feb 2011 00:01:58 -0600 Reply-To: From: "Gnanakumar" To: References: <003d01cbce71$1eaf1c90$5c0d55b0$@com> In-Reply-To: <003d01cbce71$1eaf1c90$5c0d55b0$@com> Subject: Re: Is it possible to get DISTINCT rows from RETURNING clause? Date: Fri, 18 Feb 2011 11:28:35 +0530 Organization: Zoniac Software Private Limited Message-ID: <001e01cbcf30$e35cca00$aa165e00$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AcvOcRxiF3BXtT5+S6CdBfBkL1fKlgAv6KlQ Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201102/95 X-Sequence-Number: 35171 Any ideas? -----Original Message----- From: Gnanakumar [mailto:gnanam@zoniac.com] Sent: Thursday, February 17, 2011 12:36 PM To: pgsql-sql@postgresql.org Subject: Is it possible to get DISTINCT rows from RETURNING clause? Hi, Is it possible to get DISTINCT rows from an UPDATE statement using RETURNING clause? "MYTABLE" columns are: APRIMARYKEYCOLUMN ABOOLEANCOLUMN EMAIL COLUMN1 COLUMN2 COLUMN3 UPDATE using RETURNING clause query: UPDATE MYTABLE SET ABOOLEANCOLUMN = true FROM MYTEMPTABLE WHERE EMAIL = MYTEMPTABLE.EMAIL RETURNING EMAIL, COLUMN1, COLUMN2, COLUMN3; Here in this case, I expect to return distinct rows from these columns: EMAIL, COLUMN1, COLUMN2, COLUMN3. I even tried out some ways of getting distinct rows, but it doesn't work. Though I can still solve this at application layer, I'm trying to find whether this could be controlled at query-level. Any different ideas/suggestions are appreciated. Regards, Gnanam