From: Pavel Stehule <pavel.stehule@gmail.com>
To: Tim Kane <tim.kane@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: WHERE 'Something%' LIKE ANY (array_field)
Date: Wed, 14 Aug 2013 11:55:07 +0200
Message-ID: <CAFj8pRCEx45-bFiG-kFOyJxpOYsUtj03RLLFMGuBXfKS-Sp0Fw@mail.gmail.com> (raw)
In-Reply-To: <CADVWZZJDESrQPuCj=q--PCrGVedjfJMPH__tAW8LR5b=Z+-y-A@mail.gmail.com>
References: <CADVWZZJDESrQPuCj=q--PCrGVedjfJMPH__tAW8LR5b=Z+-y-A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
Hello
http://postgres.cz/wiki/PostgreSQL_SQL_Tricks#LIKE_to_list_of_patterns
Regards
Pavel Stehule
2013/8/14 Tim Kane <tim.kane@gmail.com>
> Hi all,
>
> It seems like it isn't possible to perform a wildcard LIKE evaluation
> against array objects. Is this a bug, or just unsupported?
>
>
> See the queries in bold, that I would have expected to return a value.
> Postgres 9.1.9
>
>
> =# create temp table ids (id varchar(12)[]);
> CREATE TABLE
> Time: 185.516 ms
> =# insert into ids values ('{s1,s452334,s89}');
> INSERT 0 1
> Time: 0.728 ms
> =# insert into ids values ('{s89}');
> INSERT 0 1
> Time: 0.300 ms
> =# insert into ids values ('{s9323,s893}');
> INSERT 0 1
> Time: 0.133 ms
> =# insert into ids values ('{s9323,s893,s89}');
> INSERT 0 1
> Time: 0.110 ms
> =# select * from ids;
> id
> ------------------
> {s1,s452334,s89}
> {s89}
> {s9323,s893}
> {s9323,s893,s89}
> (4 rows)
>
> Time: 0.155 ms
> =# select * from ids where 's89' = ANY (id);
> id
> ------------------
> {s1,s452334,s89}
> {s89}
> {s9323,s893,s89}
> (3 rows)
>
> Time: 0.121 ms
> *clone=# select * from ids where 's45%' LIKE ANY (id);*
> id
> ----
> (0 rows)
>
> Time: 0.124 ms
>
> *clone=# select * from ids where 's452334%' LIKE ANY (id);*
> id
> ----
> (0 rows)
>
> Time: 0.278 ms
> clone=# select * from ids where 's452334' LIKE ANY (id);
> id
> ------------------
> {s1,s452334,s89}
> (1 row)
>
> Time: 0.134 ms
> clone=# select * from ids where 's452334' = ANY (id);
> id
> ------------------
> {s1,s452334,s89}
> (1 row)
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pavel.stehule@gmail.com, tim.kane@gmail.com
Subject: Re: WHERE 'Something%' LIKE ANY (array_field)
In-Reply-To: <CAFj8pRCEx45-bFiG-kFOyJxpOYsUtj03RLLFMGuBXfKS-Sp0Fw@mail.gmail.com>
References: <CADVWZZJDESrQPuCj=q--PCrGVedjfJMPH__tAW8LR5b=Z+-y-A@mail.gmail.com> <CAFj8pRCEx45-bFiG-kFOyJxpOYsUtj03RLLFMGuBXfKS-Sp0Fw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox