Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D802663361C for ; Wed, 26 Aug 2009 10:32:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09112-04 for ; Wed, 26 Aug 2009 13:32:04 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vw0-f190.google.com (mail-vw0-f190.google.com [209.85.212.190]) by mail.postgresql.org (Postfix) with ESMTP id A145C632F2A for ; Wed, 26 Aug 2009 10:32:04 -0300 (ADT) Received: by vws28 with SMTP id 28so89516vws.15 for ; Wed, 26 Aug 2009 06:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Pwnu6QapcJuk6aVplUmjokA5uC5MQifNIm1yf/SeW6g=; b=U/DUNO+CYqBX5UvEBHlVmL37LZyDdfkmcyyHDXrFDHJCzBxpliwhSR5w7TmTKjh8S4 1ZVfLy8BidLrDv6Py9NUkJyTyvO2G/+FRaeWAciy1+gifZr2aH8viax5wFsbpoXcsi8x ZoTQn288szzql/Yfd4p8QhcNryAkw4Ss+8NWs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=N3of5R0ofJh46i8DIpRORliseWA9E3X+sRReo1Bl45dlW9mXrYckMGhsDFlgECIQ26 Haf9bCZX7UBx1FQlEPjoSd7A1agZ5gAbmHX0JNlo1ItITzZOf/e1Q4cAJrlKQyVXPEWr GVb2FAjwFBNlZVisqdlRTXUadab5OINfHvRI4= MIME-Version: 1.0 Received: by 10.150.32.1 with SMTP id f1mr13043897ybf.96.1251293522782; Wed, 26 Aug 2009 06:32:02 -0700 (PDT) In-Reply-To: References: Date: Wed, 26 Aug 2009 15:32:02 +0200 Message-ID: <162867790908260632o685077a7xc125871fd1f6149@mail.gmail.com> Subject: Re: Selecting values from comma separated string From: Pavel Stehule To: Nacef LABIDI Cc: pgsql-sql@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/129 X-Sequence-Number: 33038 Hello postgres=# select * from foo; +---+---+ | i | a | +---+---+ | 1 | a | | 2 | b | | 3 | c | +---+---+ (3 rows) Time: 0,654 ms postgres=# select * from foo where i = ANY (string_to_array('1,3',',')::int[]); +---+---+ | i | a | +---+---+ | 1 | a | | 3 | c | +---+---+ (2 rows) Time: 0,914 ms regards Pavel Stehule 2009/8/26 Nacef LABIDI : > Hi all, > > I want to write a function that takes as param a comma separated values > string and perform a select matching these values. > > Here is the string '1,3,7,8' > > And I wan to perform a : SELECT * FROM my_table WHERE id IN (1, 3, 7, 8); > > Does anyone have a clue ? > > Thanks > > Nacef >