Re: Selecting values from comma separated string - Mailing list pgsql-sql

From Pavel Stehule
Subject Re: Selecting values from comma separated string
Date
Msg-id 162867790908260632o685077a7xc125871fd1f6149@mail.gmail.com
Whole thread Raw
In response to Selecting values from comma separated string  (Nacef LABIDI <nacef.l@gmail.com>)
List pgsql-sql
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 <nacef.l@gmail.com>:
> 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
>


pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Selecting values from comma separated string
Next
From: Pavel Stehule
Date:
Subject: Re: Selecting values from comma separated string