SQL "excluding" 字母数字条件无效

SQL "excluding" Alphanumeric condition not working

我知道有很多论坛讨论,但我认为我的情况很独特,我试图寻找所有没有字母数字值的 address1 字段,我只是用基本的查询 sql (数据库是Sybase),如下图

select  address1 from address_table where address1 like '%[^a-zA-Z0-9]%'

我的结果集包括字母数字值,

~~~~~~~~~~~~
1304 LOVERS LN
1304 LOWE AVE
1304 LYNCHBURG ST #1
1304 LYNCHBURG ST #1
1304 LYNNWOOD DR
~~~~~~~~~~~~

我不确定我错过了什么

如果我没有正确理解你的问题,你需要在你的模式中有更多的特异性来匹配 address1 字符串中任何地方 没有 字母数字字符的记录.

利用贪婪的重复修饰符 * 根据模式检查字符串中的每个字符。

select address1 from address_table where address1 like '%[^a-zA-Z0-9]*%'

您正在匹配至少有一个 non-alphanumeric 字符的任何内容。 你想要一个负数:

select  address1 from address_table where address1 not like '%[a-zA-Z0-9]%'