英文:
return strings starting with any of the characters in snowflake
问题
select * from table where name LIKE '[A-E]%';
英文:
I am trying to get all strings starting with any of the characters but it doesn't work in Snowflake. Can someone help if there is any way to do this
> select * from table where name LIKE '[A-E]%';
答案1
得分: 1
You can use rlike
instead of like
and specify a regular expression:
select * from snowflake_sample_data.tpch_sf1.nation where n_name rlike '[A-E].*';
Use a regular expression wildcard, .*
after the letters rather than a like
wildcard, %
.
For case insensitive searches, you have some options:
-- Second syntax of rlike specifying the 'i' parameter for case insensitivity.
select * from snowflake_sample_data.tpch_sf1.nation where rlike (n_name, '[a-e].*', 'i');
-- First syntax option changing the regular expression to find either upper or lower case.
select * from snowflake_sample_data.tpch_sf1.nation where n_name rlike '[A-Ea-e].*';
英文:
You can use rlike
instead of like
and specify a regular expression:
select * from snowflake_sample_data.tpch_sf1.nation where n_name rlike '[A-E].*';
Use a regular expression wildcard, .*
after the letters rather than a like
wildcard, %
.
For case insensitive searches, you have some options:
-- Second syntax of rlike specifying the 'i' parameter for case insensitivity.
select * from snowflake_sample_data.tpch_sf1.nation where rlike (n_name, '[a-e].*', 'i');
-- First syntax option changing the regular expression to find either upper or lower case.
select * from snowflake_sample_data.tpch_sf1.nation where n_name rlike '[A-Ea-e].*';
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论