Re: WHERE 'Something%' LIKE ANY (array_field)

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Tim Kane <tim(dot)kane(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: WHERE 'Something%' LIKE ANY (array_field)
Date: 2013-08-14 18:23:50
Message-ID: 1376504630.5670.YahooMailNeo@web162904.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tim Kane <tim(dot)kane(at)gmail(dot)com> wrote:

> I'm using a single LIKE clause against an array parameter, rather
> than multiple LIKE clauses against a single parameter.

The problem is that you have the arguments to the LIKE parameter
reversed with the attempts you show.  Try something like this:

select * from ids
  where exists
   (select * from (select unnest(ids.id)) x(id)
                     where x.id like 's45%');

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2013-08-14 18:28:06 Re: Seemingly inconsistent ORDER BY behavior
Previous Message Richard Hipp 2013-08-14 18:01:36 Seemingly inconsistent ORDER BY behavior