Re: [SQL ] 找交集

看板Database作者 (Archq)時間17年前 (2007/06/17 01:42), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串6/6 (看更多)
※ 引述《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)
文章代碼(AID): #16T24Xxc (Database)
文章代碼(AID): #16T24Xxc (Database)