SELECT code , name , dept, occupation FROM staff WHERE instr('A10001,A10002',code)>0;
查询出来结果一样,这样前后只用到两次单引号,相对方便点。
还有一个用法,如下:
SELECT code, name, dept, occupation FROM staff WHERE instr(code, '001') > 0;
等同于
SELECT code, name, dept, occupation FROM staff WHERE code LIKE '%001%' ;
源字符为空字符串''的情况
-- Created on 2010-12-22 by CHEN
declare
-- Local variables here
i varchar2(2);
begin
-- Test statements here
i := instr('',',');
if i is null then
dbms_output.put_line(' i is empty');
end if;
end;