SELECT code , name , dept, occupation FROM staff WHERE instr('A10001,A10002',code)>0;
查詢出來結(jié)果一樣,這樣前后只用到兩次單引號,相對方便點。
還有一個用法,如下:
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;