Oracle截取电子信箱问题?

13abyKnight 2010-06-23 12:02:44
如何,将数据库的电子数据截取呢。

如:

1.zb@qq.com 只要zb

2.absss@qq.com 只要absss


谢谢
...全文
104 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ngx20080110 2010-06-23
  • 打赏
  • 举报
回复
regexp_replace可以放在where中使用的,所以可以截取后再与传进来的前缀比较
13abyKnight 2010-06-23
  • 打赏
  • 举报
回复
比如,我界面传进来的是电子信箱的前缀 那么,我根据前缀的信息查询数据库表中相应数据。
13abyKnight 2010-06-23
  • 打赏
  • 举报
回复
是啊,我想根据截取完条件的数据和ZB相等的数据查出来
ngx20080110 2010-06-23
  • 打赏
  • 举报
回复
可以的

with tmp as
(
select 'zb@qq.com' email from dual union all
select 'test@qq.com.cn' email from dual union all
select 'test@163.com' email from dual union all
select 'absss@qq.com' email from dual
)
select email
from tmp
where regexp_replace(email, '(\w+)@(\w+\.)+\w{2,3}', '\1') = 'zb';

EMAIL
---------------------
zb@qq.com
13abyKnight 2010-06-23
  • 打赏
  • 举报
回复
我想在写条件的时候进行截取。在截取的过程中进行判断
13abyKnight 2010-06-23
  • 打赏
  • 举报
回复
还在嘛?
如果,说是表中有一列数据都是@163.com结尾的情况下,我想在写sql语句的时候可不可以将当前的着一列数据信息截取呢!!
比如:
select id from ty_nc_tw_mapping a where a.regexp_replace(email, '(\w+)@(\w+\.)+\w{2,3}', '\1') ='zb'

是否可以呢
ngx20080110 2010-06-23
  • 打赏
  • 举报
回复

with tmp as
(
select 'zb@qq.com' email from dual union all
select 'test@qq.com.cn' email from dual union all
select 'absss@qq.com' email from dual
)
select regexp_replace(email, '(\w+)@(\w+\.)+\w{2,3}', '\1') result
from tmp;

RESULT
--------------
zb
test
absss
ngx20080110 2010-06-23
  • 打赏
  • 举报
回复

with tmp as
(
select 'zb@qq.com' email from dual union all
select 'test@qq.com.cn' email from dual union all
select 'absss@qq.com' email from dual
)
select regexp_replace(email, '(\w+)@(\w+\.)+\w{2,3}', '\1') result
from tmp;

RESULT
-------zb
test
absss
13abyKnight 2010-06-23
  • 打赏
  • 举报
回复
顶一下

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧