在日常开发中,查询时会遇到数据库值为m(a,b,c,d,e,f,g),传入条件为n(b,c)
以下为varchar2类型,仅供参考:
CREATE OR REPLACE
function strIntersectionCount(source varchar2,target varchar2) return number
as
v_pric number;
begin
select count(*) into v_pric from (
select regexp_substr(source, ',', 1, rownum) nme
from dual
connect by rownum <= length(regexp_replace(source, ',')) +1
intersect
select regexp_substr(target, ',', 1,rownum) nme
from dual
connect by rownum <= length(regexp_replace(target, ',')) +1);
return v_pric;
end strIntersectionCount;
用法示例:
数据库值:1,3,5,6,7,8
传入条件:3,5
select * from dual where strIntersectionCount(