Re: [SQL ] 請問要如何搜尋兩張資料表
很感謝chunhsiang 的解惑
剛測試過可行,但遇有個小小問題是兩張10萬筆的資料做此動作大概需要跑3-4秒
所以最後改寫成
select a.id as id, a.enable as enable
from a
where a.enable is not null
輸出成陣列 a_arry
select b.id, b.enable
from b
where b.enable is not null
輸出成陣列 b_arry
在將兩陣列合併
※ 引述《chunhsiang (= =)》之銘言:
: ※ 引述《phreat (雷)》之銘言:
: : 請問一下
: : 以下為兩張表
: : table a
: : id enable
: : 1
: : 2 1
: : 3 1
: : 4 1
: : table b
: : id enable
: : 4 1
: : 5 1
: : 6 1
: : 請問有辦法印出
: : id enable
: : 2 1
: : 3 1
: : 4 1
: : 4 1
: : 5 1
: : 6 1
: : 測試過FULL JOIN , UNION 等都無法達成如果使用
: : select * from a as a ,b as b
: : 會變成
: : id enable id enable
: : ....
: : ....
: : ....
: : ....
: select a.id as id, a.enable as enable
: from a
: where a.enable is not null
: union all
: select b.id, b.enable
: from b
: where b.enable is not null
: ;
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 112.105.189.66
→
09/01 03:10, , 1F
09/01 03:10, 1F
→
09/01 03:23, , 2F
09/01 03:23, 2F
→
09/01 23:56, , 3F
09/01 23:56, 3F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 3 篇):