SELECT USERID, USERNAME FROM TB_USERS WHERE USERID IN (1,2,3,4,5)
select * from tablename where id in(1,2,3,4,5)
create table t1 as select * from ( select 1 id , 'A1' name from dual union all select 2 id , 'A2' name from dual union all select 3 id , 'A3' name from dual union all select 4 id , 'A4' name from dual union all select 5 id , 'A5' name from dual );select * from t1 where instr(',1,2,3,4,5,',','||id||',') > 0
其中instr的两个参数前后都要用分隔符','拼起来,否则可能出现不需要的信息。
语句很直接 where id in(1,2,3,4,5)
动态cursor open cursor for select * from table where col in('||instr||')';
select * from t_user where user_id in (1,2,3,4,5);
as
select * from (
select 1 id , 'A1' name from dual
union all
select 2 id , 'A2' name from dual
union all
select 3 id , 'A3' name from dual
union all
select 4 id , 'A4' name from dual
union all
select 5 id , 'A5' name from dual
);select * from t1
where instr(',1,2,3,4,5,',','||id||',') > 0
where id in(1,2,3,4,5)
open cursor for select * from table where col in('||instr||')';