'List the title of all books in the same category as books previously purchased by customers 2010, 2011, 2012, without before bought books by them

In oracle SQL, I tried this to get the output for 2010 just to check and it works but could not get the answer for all at once

SELECT title FROM books WHERE category IN (SELECT DISTINCT category FROM b_books
            JOIN orderitems USING ( isbn )
            JOIN orders USING ( order# )
        WHERE customer# = 2010) AND isbn NOT IN (SELECT isbn
        FROM orders
            JOIN orderitems USING ( order# ) WHERE customer# = 2010 );

But I tried a lot of ways to get for 2010,2011,2012 at once using 'AND', 'comma' and other ways but could not get the output. So please can you help me?

sql


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source