赞
踩
在日常使用SQL导数据时,会遇到这样一个问题。
select * from tab1 where id in(1,2,3);
这是一个很简单的语句,但是存在一个问题,如果in里面不是3个选择,而是10000个选择。这时候难道写成这样:
select * from tab1 where id in(1,2,3,4,....10000);
这样写未免太过繁琐,而且存在一个问题。Oracle限制了in子句不能超过1000行。。。。。 写成这样压根就运行不了!!!
①创建一个表test,把数据复制粘贴进去。
create table test(
id varchar2(50)
);
②利用内连接或者子查询达到上述效果。
内连接:
select a.* from tab1 a inner join test b on a.id=b.id;
子查询:
select * from tab1 where id in (select id from test);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。