Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NOT LIKE ANY query in Snowflake

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.

like image 570
Saqib Ali Avatar asked Jan 13 '20 05:01

Saqib Ali


People also ask

How do you use like functions in snowflakes?

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 : %, _.

How do you use not like?

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.

What is the difference between like and Ilike in Snowflake?

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.


Video Answer


1 Answers

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.

like image 78
David Garrison Avatar answered Sep 22 '22 07:09

David Garrison