可用instr函数。
创新互联建站专业为企业提供罗山网站建设、罗山做网站、罗山网站设计、罗山网站制作等企业网站建设、网页设计与制作、罗山企业网站模板建站服务,十多年罗山做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。
如:
select instr('sdfcontain234','contain') from dual;
结果:
如果返回值大于0,则表示字符串中包含contain。
再如:
select instr('sdfcontn234','contain') from dual;
结果:
如果返回值为0,则代表字符串中不包含contain。
前闭后开(30 = xxx 50)只能用 = xxx 来连接
WHERE xxx = 30 AND xxx 50
如果是前后都闭合(30= xxx = 50)那么可以用BETWEEN XX AND xxx
WHERE XXX BETWEEN 30 AND 50
select sum(case when flag1+falg2=11 then 1 else 0 end) as 既含有国产又有自制的,
sum(case when flag1+falg2=1 then 1 else 0 end) as 只有国产的,
sum(case when flag1+falg2=10 then 1 else 0 end) as 只有自制的
from (
select (case when instr(药品来源,'国产')0 then 1 else 0 end ) as flag1,
(case when instr(药品来源,'自制')0 then 10 else 0 end ) as flag2
from table_name
) t
直接写就可以
create or replace trigger checkmodulecount
before insert on registration
for each row
declare
moduleCount number;
ex exception;
begin
select count(moduleid) into moduleCount
from registration r,student s
where r.studentid=:new.studentid
and r.studentid=s.studentid
and (r.semester='2' or r.semester='1');
select lastname into tname from students where studentid=:new.studentid;
if moduleCount 4 then
dbms_output.put_line('Module registered successful');
else
raise ex;
end if;
exception
when ex then
raise_application_error(-20000, 'Student '|| s.lastname|| ' ID '||studentid || ' has register 4 modules already, the number of module for a particular semester should not exceed 4');
end;
plsql developer中 有个“小望远镜图标的”搜索功能
select TABLE_NAME from user_tab_columns where column_name Like '%K%'
select * from a where instr(a,b)0;
这个只能实现B字段是A字段中的某一部分的时候,
如果想要不论顺序或者不相邻的字符时,定义函数可以实现
create or replace function checks(v_a varchar2,v_b varchar)
return number
as
num number;
cou number;
begin
num := -1;
cou:=0;
for i in 1..length(v_b) loop
if instr(v_a,substr(v_b,i,1))0 then
cou:=cou+1;
end if;
end loop;
if cou=length(v_b) then
return cou;
end if;
dbms_output.put_line(cou||' '||length(v_b));
return num;
end;
结果:
SQL select * from a;
A B
---------- ----------
asdf sd
asdf ad
asdf df
asdf asdf
SQL select * from a where checks(a,b)0;
A B
---------- ----------
asdf sd
asdf ad
asdf df
asdf asdf
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款