informix DB 中是否有任何 alpha 逻辑定义
is there are any alpha logic define in informix DB
我正在使用 informix DB,我需要获取在最后一个字符上包含字母 [A-Za-z] 字符的记录
我尝试的是:
select * from table_name
where (SUBSTR(trim(customer),-1,1)!='0' and SUBSTR(trim(customer),-1,1)!='1' and SUBSTR(trim(customer),-1,1)!='2' and SUBSTR(trim(customer),-1,1)!='3' and SUBSTR(trim(customer),-1,1)!='4' and SUBSTR(trim(customer),-1,1)!='5' and SUBSTR(trim(customer),-1,1)!='6' and SUBSTR(trim(customer),-1,1)!='7' and SUBSTR(trim(customer),-1,1)!='8' and SUBSTR(trim(customer),-1,1)!='9') or (SUBSTR(trim(customer),-1,1)=' ') or (SUBSTR(trim(customer),-1,1)='') or (customer IS NULL)
有没有办法写 where SUBSTR(trim(customer),-1,1)=alpha 而不是写
SUBSTR(trim(客户),-1,1)!='0' 和 SUBSTR(trim(客户),-1,1)!='1' 和 SUBSTR (trim(客户),-1,1)!='2' 和 SUBSTR(trim(客户),-1,1)!='3' 和 SUBSTR(trim (客户),-1,1)!='4' 和 SUBSTR(trim(客户),-1,1)!='5' 和 SUBSTR(trim(客户),-1 ,1)!='6' 和 SUBSTR(trim(客户),-1,1)!='7' 和 SUBSTR(trim(客户),-1,1)!=' 8' 和 SUBSTR(trim(客户),-1,1)!='9'
如果您有 'recent' 版本的 Informix(任何超过 12.10 的版本都可以),您可以使用 regex_match():
https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.dbext.doc/ids_dbxt_544.htm
类似于:
> select * from table(set{'test','test1','tesT'})
where regex_match(unnamed_col_1, '[a-zA-Z]$');
unnamed_col_1
test
tesT
2 row(s) retrieved.
>
您可以使用任何版本都支持的 Informix MATCHES 运算符。
查询将是这样的:
select * from table_name
where customer matches "*[A-Za-z]"
我正在使用 informix DB,我需要获取在最后一个字符上包含字母 [A-Za-z] 字符的记录 我尝试的是:
select * from table_name
where (SUBSTR(trim(customer),-1,1)!='0' and SUBSTR(trim(customer),-1,1)!='1' and SUBSTR(trim(customer),-1,1)!='2' and SUBSTR(trim(customer),-1,1)!='3' and SUBSTR(trim(customer),-1,1)!='4' and SUBSTR(trim(customer),-1,1)!='5' and SUBSTR(trim(customer),-1,1)!='6' and SUBSTR(trim(customer),-1,1)!='7' and SUBSTR(trim(customer),-1,1)!='8' and SUBSTR(trim(customer),-1,1)!='9') or (SUBSTR(trim(customer),-1,1)=' ') or (SUBSTR(trim(customer),-1,1)='') or (customer IS NULL)
有没有办法写 where SUBSTR(trim(customer),-1,1)=alpha 而不是写 SUBSTR(trim(客户),-1,1)!='0' 和 SUBSTR(trim(客户),-1,1)!='1' 和 SUBSTR (trim(客户),-1,1)!='2' 和 SUBSTR(trim(客户),-1,1)!='3' 和 SUBSTR(trim (客户),-1,1)!='4' 和 SUBSTR(trim(客户),-1,1)!='5' 和 SUBSTR(trim(客户),-1 ,1)!='6' 和 SUBSTR(trim(客户),-1,1)!='7' 和 SUBSTR(trim(客户),-1,1)!=' 8' 和 SUBSTR(trim(客户),-1,1)!='9'
如果您有 'recent' 版本的 Informix(任何超过 12.10 的版本都可以),您可以使用 regex_match():
https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.dbext.doc/ids_dbxt_544.htm
类似于:
> select * from table(set{'test','test1','tesT'})
where regex_match(unnamed_col_1, '[a-zA-Z]$');
unnamed_col_1
test
tesT
2 row(s) retrieved.
>
您可以使用任何版本都支持的 Informix MATCHES 运算符。 查询将是这样的:
select * from table_name
where customer matches "*[A-Za-z]"