返回以snowflake中任何字符开头的字符串。

huangapple go评论46阅读模式
英文:

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].*';

huangapple
  • 本文由 发表于 2023年2月14日 01:16:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75439154.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定