計算機科学のブログ

ほしい物リスト

SQL - SQLite - Python - サブクエリ - クエリの中にあるクエリ - 相関サブクエリ, EXISTS, NOT EXISTS

Head First SQL ―頭とからだで覚えるSQLの基本Lynn Beighley(著)、 佐藤 直生(監訳)、 松永 多苗子(翻訳)、 オライリージャパンの 9章(サブクエリ - クエリの中にあるクエリ)、p.411(自分で考えてみよう)の解答を求めてみる。

schema4.sql

select mc.email 
from my_contacts mc
where exists (select * from contact_interests ci
              where mc.contact_id = ci.contact_id)
and not exists (select * from job_current jc
                where mc.contact_id = jc.contact_id);