作者swangs (Archq)
看板Database
标题Re: [SQL ] 找交集
时间Sun Jun 17 01:42:54 2007
※ 引述《retsamsu (haha)》之铭言:
: ※ 引述《asio1 (牛奶)》之铭言:
: : 其实我是在做dataming的作业,在寻找资料的特性
: : 所以资料库才会这样大
: : 可以请你解释一下做法吗 我用的是mySQL 的环境
: : 因为其实table_1 与table_2 都是两个query出的结果,所以是没有index的
: : 但是各别执行都花不到一秒 但是做卡氏积就太大了
: 那就照 flakchen 说的试试看吧
: select count(*) from table_1 where table_1.col1 in (select col1 from table_2)
select count(*) from table_1 a
where exists (
select col1 from table_2 b where a.col1 = b.col1
)
用exists据说会比in有效率
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.73.235.198
※ 编辑: swangs 来自: 203.73.235.198 (06/17 01:43)