postgresql SQL 查询其中字段不包含数字

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26451191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:39:33  来源:igfitidea点击:

SQL Query Where Field DOES NOT Contain a Digit

sqlpostgresql

提问by liv a

I have a table with an address street, I want to make sure the address contains the street as well as house/building number (saxon 17) I want to write an SQL query to find rows where field address does not contain a numeric value. How can I do this?

我有一个带有地址街道的表,我想确保地址包含街道以及房屋/建筑物编号(撒克逊 17) 我想编写一个 SQL 查询来查找字段地址不包含数值的行。我怎样才能做到这一点?

回答by a_horse_with_no_name

This can be done using a regular expression:

这可以使用正则表达式来完成:

select *
from the_table
where address_column !~ '[0-9]'

More details about regular expressions and pattern matching can be found in the manual:
http://www.postgresql.org/docs/current/static/functions-matching.html

有关正则表达式和模式匹配的更多详细信息,请参见手册:http:
//www.postgresql.org/docs/current/static/functions-matching.html