Re: where col1 not ilike ('str1%', 'str2%'... 'strN%') support? - Mailing list pgsql-sql

From Jasen Betts
Subject Re: where col1 not ilike ('str1%', 'str2%'... 'strN%') support?
Date
Msg-id j3l1oe$r4i$1@reversiblemaps.ath.cx
Whole thread Raw
In response to where col1 not ilike ('str1%', 'str2%'... 'strN%') support?  (Emi Lu <emilu@encs.concordia.ca>)
List pgsql-sql
On 2011-08-30, Emi Lu <emilu@encs.concordia.ca> wrote:
> Hi Tom,
>
>>>> select * from tablename
>>>> where not (col1 ~~* any(array['str1%', 'str2%'... 'strN%']));
>>
>>> If next version could have "not ilike ('', '')" added into window
>>> functions, that's will be great!
>>
>> Why?  And what's this got to do with window functions?
>
> First, where not (col1 ~~* any(array['str1%', 'str2%'... 'strN%'])) will 
> work for me.
>
> But I feel " ilike ('str1', ... 'strN')" is more intuitive, isn't it?

no, "('str1', ... 'strN')"  looks a lot like a tuple.


if you know these strings beforehand use a single regular expression
instead because ilike is just regex in drag (postgres uses regex to do
ilike), and while ilike can only check one pattern at a time regex can
check several simultaneously.
foo ~* '^(str1|str2|str3...|strN)$'

-- 
⚂⚃ 100% natural



pgsql-sql by date:

Previous
From: Emre Hasegeli
Date:
Subject: Re: where col1 not ilike ('str1%', 'str2%'... 'strN%') support?
Next
From: Emi Lu
Date:
Subject: Re: where col1 not ilike ('str1%', 'str2%'... 'strN%') support?