oracle 数字对比,在oracle中将数字作为字符串进行比较

这就是你要找的吗?

create table address as

select

'01 park avenue' address1,

'20 golden gate' address2,

'30 test' address3

from

dual;

insert into address

select

'01 park avenue' address1,

'20 golden gate' address2,

null address3

from

dual;

insert into address

select

'01 park avenue' address1,

'20 golden gate' address2,

null address3

from

dual;

commit;

下面是一个查询,它将通过按连接的数字字符串排序来查找“重复项”。我们使用地址连接上的regexp_replace从地址中提取数字。

select

address1 || address2 || address3 address_concat,

regexp_replace(address1 || address2 || address3, '[^[:digit:]]')

address_numbers_only

from

address

order by

address_numbers_only;

如果要查找与特定地址匹配的项,请尝试以下操作:

select

*

from

address

where

regexp_replace(address1 || address2 || address3, '[^[:digit:]]') =

regexp_replace(:v_address1 ||

:v_address2 ||

:v_address3, '[^[:digit:]]');

例如:

select

*

from

address

where

regexp_replace(address1 || address2 || address3, '[^[:digit:]]') =

regexp_replace('01 park avenue' ||

'20 golden gate' ||

null, '[^[:digit:]]');

-- returns...

ADDRESS1 ADDRESS2 ADDRESS3

01 park avenue 20 golden gate

01 park avenue 20 golden gate

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值