Subqueries Introduced with NOT EXISTS

NOT EXISTS works just like EXISTS, except that the WHERE clause in which it is used is satisfied if no rows are returned by the subquery.

For example, to find the names of publishers who do not publish business books:

SELECT pub_name
FROM publishers
WHERE NOT EXISTS
    (SELECT *
    FROM titles
    WHERE pub_id = publishers.pub_id
        AND type = 'business')

This query finds the titles for which there have been no sales:

SELECT title
FROM titles
WHERE NOT EXISTS
    (SELECT title_id
    FROM sales
    WHERE title_id = titles.title_id)

title
----------------------------------
The Psychology of Computer Cooking
Net Etiquette

(2 row(s) affected)