What's the best way in postgres to use ANY() with LIKE '%'?

From: Ryan Murphy <ryanfmurphy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: What's the best way in postgres to use ANY() with LIKE '%'?
Date: 2017-09-05 02:10:01
Message-ID: CAHeEsBfQ79-ZOqWPTzFHVDpzbVX3uHktQOVAKAy-7huu7XzctQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

e.g. I know you can do

select * from post
where 'music' = any(tags);

Which is similar to saying tags @> '{music}'.

And I see that I can even do:

select * from post
where 'music' LIKE any(tags);

...implying that ANY is more general in some ways than @>,
e.g. it can would with LIKE as well as =.

But is there any way to do:

select * from post
where any(tags) LIKE 'music%';

??

This doesn't work because ANY is only allowed on the right.

Thanks!
Ryan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message reugen1984 2017-09-05 02:37:23 hidden maintenance_work_mem limitations of a Windows build
Previous Message Steve Atkins 2017-09-04 21:18:55 Re: Create Action for psql when NOTIFY Recieved