2

他のテーブルのIDに基づいて、自分のテーブルの行を除外しようとしています。2つのテーブルがあり、そのうちの「select * from」は、(1,2,3)のようなセットになります。

次のように、これら2つのサブクエリの結果を1つにまとめようとしています。

(1,2,3) + (4,5) = (1,2,3,4,5)

したがって、「NOT IN(1,2,3,4,5)」で大きなテーブルをフィルタリングできます。

GROUP_CONCATやUNIONなどを見てきましたが、実際に機能するものが見つからないようです。

誰かアイデアがありますか?

4

2 に答える 2

1
select *
from Table3 
where id not in (
    select id from Table1 --your subquery that returns 1,2,3
    union all
    select id from Table2 --your subquery that returns 4,5
)
于 2012-10-17T15:57:43.630 に答える
0
select * from mytable
where id not in (
    select id from othertable
    union
    select id from othertable2
)
于 2012-10-17T15:58:45.077 に答える