I am trying to run the following query in Snowflake:
SELECT * FROM chapters
WHERE
title NOT LIKE ANY ('Summary%', 'Appendix%')
but it errors out. I know Snowflake support LIKE ANY query syntax. But I am not sure why my query is not working.
There are certain use case scenarios when it is recommended to use the Like function within the Snowflake cloud data warehouse which are as follows: You want to match the column value on only one pattern. You want to match the input using SQL based wildcards, for example : %, _.
The NOT LIKE operator in SQL is used on a column which is of type varchar . Usually, it is used with % which is used to represent any string value, including the null character \0 . The string we pass on to this operator is not case-sensitive.
Allows matching of strings based on comparison with a pattern. Unlike the LIKE function, string matching is case-insensitive. LIKE, ILIKE, and RLIKE all perform similar operations; however, RLIKE uses POSIX EXE (Extended Regular Expression) syntax instead of the SQL pattern syntax used by LIKE and ILIKE.
It does seem like that syntax with NOT should work, and I'm not quite sure why it doesn't, but this works.
SELECT * FROM chapters
WHERE
NOT (title LIKE ANY ('Summary%', 'Appendix%'))
Extra parens are optional, but seems more clear to me when it's "worded" this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With