--这些是外面传入的字符串 yuanpan/32489,zhoujielun/32569,zhangbo/35698
create table student
(
stuid number,
stuname varchar2(100)
);insert into student values(1001,'yuanpan/32489');
insert into student values(2001,'zhoujielun/32569');
insert into student values(3001,'zhangbo/35698');insert into student values(4001,'yuanpanaa/45687');
insert into student values(5001,'zhoujielunbb/56984');
insert into student values(6001,'zhangbovv/39741');---根据传入的字符串动态的获取这样的结果 ,1001,2001,3001, 字符串模糊匹配
SQL> drop table student;Table droppedSQL> create table student
2 (
3 stuid number,
4 stuname varchar2(100)
5 );Table createdSQL>
SQL> insert into student values(1001,'yuanpan/32489');1 row insertedSQL> insert into student values(2001,'zhoujielun/32569');1 row insertedSQL> insert into student values(3001,'zhangbo/35698');1 row insertedSQL> insert into student values(4001,'yuanpanaa/45687');1 row insertedSQL> insert into student values(5001,'zhoujielunbb/56984');1 row insertedSQL> insert into student values(6001,'zhangbovv/39741');1 row insertedSQL> commit;Commit completeSQL> select wm_concat(stuid) from student where instr('yuanpan/32489,zhoujielun/32569,zhangbo/35698',stuname)>0;WM_CONCAT(STUID)
--------------------------------------------------------------------------------
1001,2001,3001SQL> drop table student;Table droppedSQL>
select stuid from student
where instr('yuanpan/32489,zhoujielun/32569,zhangbo/35698',stuname)>0
STUID
----------
1001
2001
3001
--这些是外面传入的字符串 yuanpan/32489,zhoujielun/32569,zhangbo/35698
create table student
(
stuid number,
stuname varchar2(100)
);insert into student values(1001,'yuanpan 32489');
insert into student values(2001,'zhoujielun 32569');
insert into student values(3001,'zhangbo 35698');insert into student values(4001,'yuanpanaa 45687');
insert into student values(5001,'zhoujielunbb 56984');
insert into student values(6001,'zhangbovv 39741');---根据传入的字符串动态的获取这样的结果 ,1001,2001,3001, 字符串模糊匹配
1 select replace(wm_concat(stuid),',','、') from student
2* where regexp_like('yuanpan/32489,zhoujielun/32569,zhangbo/35698',stuname)
SQL> /REPLACE(WM_CONCAT(STUID),',','、')
--------------------------------------------------------------------------------
1001、2001、3001SQL>
when wm_concat(id) is null then
'Not Found'
else
',' || wm_concat(id) || ','
end
from hw_acl_user_t
where instr(lower('...yuanpan 0032489,zhaoxiaoming 001017555,fengdan 00126235'),
lower(full_name)) > 0;
select case
when wm_concat(id) is null then
'Not Found'
else
',' || wm_concat(id) || ','
end
from hw_acl_user_t
where regexp_like(lower('chensong 00105121,chesnyong 50417,chenyonghong'),
lower(full_name));
--用instr 和 regexp_like 哪种比较好? 两种得出的结果没有区别