Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 1DFF0634376 for ; Tue, 7 Sep 2010 08:51:46 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 92087-03 for ; Tue, 7 Sep 2010 11:51:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gmx.net (mailout-de.gmx.net [213.165.64.23]) by mail.postgresql.org (Postfix) with SMTP id A4F62633110 for ; Tue, 7 Sep 2010 08:51:38 -0300 (ADT) Received: (qmail invoked by alias); 07 Sep 2010 11:51:34 -0000 Received: from mue-88-130-57-157.dsl.tropolys.de (EHLO [192.168.0.113]) [88.130.57.157] by mail.gmx.net (mp009) with SMTP; 07 Sep 2010 13:51:34 +0200 X-Authenticated: #14269776 X-Provags-ID: V01U2FsdGVkX1/jO6MzXVTjc0ChBjEfjCdXThxwu1AuBXmHyv2X/5 K4vpmXyjy9Ql4t Message-ID: <4C862773.2070900@gmx.net> Date: Tue, 07 Sep 2010 13:52:19 +0200 From: Andreas User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: is there a distinct function for comma lists ? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/12 X-Sequence-Number: 34543 Hi, is there a distinct function for comma separated lists ? I sometimes need to update tables where I got a set of IDs, like: update mytable set someattribute = 42 where mytable.id in ( 1, 2, 3, 5, 7, 11, 3, 6, 13, 13, 3, 11 ... ) So there are double entries in the list but in this case its just overhead but no problem. But for calculated values this would not allways be desirable. update mytable set someattribute = someattribute + 1 where mytable.id in ( 1, 2, 3, 5, 7, 11, 3, 6, 13, 13, 3, 11 ... ) How could I get a distinct list? Those lists can have 2000-3000 IDs sometimes. One solution was as follows but perhaps there is something more elegant? update mytable set someattribute = someattribute + 1 where mytable.id in ( select distinct id from mytable where id in ( 1, 2, 3, 5, 7, 11, 3, 6, 13, 13, 3, 11 ... ) ) And as bonus ... is there a way to find IDs that are in the list but not in the table without creating a temporary table and use a join?