>その2つのテーブルの差分を知りたいのですが、 >(Aを基準と考えBとの差分:つまりAには存在しないデータ抽出) Aを基準なら、普通は「Aにあり、Bにない」だと思いますが? 紛らわしいので、「t1にあり、t2にはない」として、SQL例を示します。 -- 例1 not existsを使う select c1 from t1 where not exists(select * from t2 where t1.c1=c1) -- 例2 not inを使う select c1 from t1 where c1 not in(select c1 from t2) -- 例3 left joinを使う select t1.c1 from t1 left join t2 on t1.c1=t2.c1 where t2.c1 is null
![テーブル間の差分抽出方法は? - クエリー文 - OKWAVE](https://cdn-ak-scissors.b.st-hatena.com/image/square/a3202632a5b19efa6d7dbcca644fc13bfa3453dc/height=288;version=1;width=512/https%3A%2F%2Fgazo.okwave.jp%2Fokwave%2Fspn%2Fimages%2Flogo%2Ffacebook_okwave.jpg)