17,086
社区成员
发帖
与我相关
我的任务
分享
--首先把用户输入的几千个product_name插入一个临时表,然后用join去连接,这样的话很快,比你用in,循环快多了
select a.product_name, a.deliver from product a
INNER JOIN #tab b ON a.product_name=b.product_name
--where product_name in (用户输入的几千个name)
[/quote]
具体怎么写sql呢?
--首先把用户输入的几千个product_name插入一个临时表,然后用join去连接,这样的话很快,比你用in,循环快多了
select a.product_name, a.deliver from product a
INNER JOIN #tab b ON a.product_name=b.product_name
--where product_name in (用户输入的几千个name)
--1.创建一个临时表,存储用户输入的几千个name
create table tmp as select 用户输入的几千个name as product_name from dual;
--2.SQL实现
select a.product_name, a.deliver
from product a
where exists (select null from tmp b where b.product_name = a.product_name);
--首先把用户输入的几千个product_name插入一个临时表,然后用join去连接,这样的话很快,比你用in,循环快多了
select a.product_name, a.deliver from product a
INNER JOIN #tab b ON a.product_name=b.product_name
--where product_name in (用户输入的几千个name)
[/quote]
具体怎么写sql呢?[/quote]
不是说的很清楚了吗?把你in里面的内容单独插入一个表,然后用上面的连接方式连接一下