Thread: where col1 not ilike ('str1%', 'str2%'... 'strN%') support?
Good morning, Does psql provide something like the following query command? select * from tablename where col1 not ilike ('str1%', 'str2%'... 'strN%') Thanks a lot! Emi
use a regex ? On 08/30/2011 16:51, Emi Lu wrote: > Good morning, > > Does psql provide something like the following query command? > > select * from tablename > where col1 not ilike ('str1%', 'str2%'... 'strN%') > > Thanks a lot! > Emi > -- No trees were killed in the creation of this message. However, many electrons were terribly inconvenienced.
Attachment
Emi Lu <emilu@encs.concordia.ca> writes: > Does psql provide something like the following query command? > select * from tablename > where col1 not ilike ('str1%', 'str2%'... 'strN%') If you remember the operator name equivalent to ILIKE (~~*) you can do select * from tablename where not (col1 ~~* any(array['str1%', 'str2%'... 'strN%'])); regards, tom lane
On 08/30/2011 11:24 AM, Tom Lane wrote: > Emi Lu<emilu@encs.concordia.ca> writes: >> Does psql provide something like the following query command? > >> select * from tablename >> where col1 not ilike ('str1%', 'str2%'... 'strN%') > > If you remember the operator name equivalent to ILIKE (~~*) > you can do > > select * from tablename > where not (col1 ~~* any(array['str1%', 'str2%'... 'strN%'])); Thank you Tom! If next version could have "not ilike ('', '')" added into window functions, that's will be great! Emi
Emi Lu <emilu@encs.concordia.ca> writes: > On 08/30/2011 11:24 AM, Tom Lane wrote: >> 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? regards, tom lane
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? I have a feeling that windows functions deal with all fancy functions. I would consider ilike ('str'...) as a non-standard SQL command? Emi
2011/8/30 Emi Lu <emilu@encs.concordia.ca>: > 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? It is not. It is like "where id = (3, 5, 7)". -- Emre Hasegeli Veri Tabanı Yöneticisi Tart İnternet Teknolojileri AŞ tart.com.tr
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
On 08/31/2011 03:16 AM, Emre Hasegeli wrote: > 2011/8/30 Emi Lu<emilu@encs.concordia.ca>: > >> 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? > > It is not. It is like "where id = (3, 5, 7)". What I mean is ilike ('%str1%', ... '%strN%') I just forgot to put % Emi
2011/8/31 Emi Lu <emilu@encs.concordia.ca>: > On 08/31/2011 03:16 AM, Emre Hasegeli wrote: >> >> 2011/8/30 Emi Lu<emilu@encs.concordia.ca>: >> >>> 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? >> >> It is not. It is like "where id = (3, 5, 7)". > > > What I mean is ilike ('%str1%', ... '%strN%') > > I just forgot to put % it useless to introduce non SQL feature where some native feature exists now. Regards Pavel Stehule > > Emi > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql >