确定邮政编码是否仅包含数字 [英] Determine if zip code contains numbers only

查看:331
本文介绍了确定邮政编码是否仅包含数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为zip的字段,键入char(5),其中包含邮政编码,如

I have a field called zip, type char(5), which contains zip codes like

12345
54321
ABCDE

我想检查一个sql语句,如果邮政编码包含

I'd like to check with an sql statement if a zip code contains numbers only.

以下内容无效

SELECT * FROM S1234.PERSON
WHERE ZIP NOT LIKE '%'

它不能工作,因为甚至'12345'是一个数组的字符(它是'%',对吗?

It can't work because even '12345' is an "array" of characters (it is '%', right?

我发现以下是工作:

SELECT * FROM S1234.PERSON
WHERE ZIP NOT LIKE ' %'

它之前有一个空格,为什么这样工作?

It has a space before %. Why is this working?

推荐答案

尝试检查小写和大写字母之间是否有区别,数字和特殊字符看起来是一样的:

Try checking if there's a difference between lower case and upper case. Numerics and special chars will look the same:

SELECT *
FROM S1234.PERSON 
WHERE UPPER(ZIP COLLATE Latin1_General_CS_AI ) = LOWER(ZIP COLLATE Latin1_General_CS_AI)

这篇关于确定邮政编码是否仅包含数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆