Coding task · SQL and MySQL course · Module 8: Subqueries
Authors whose books are never borrowed
Combine NOT EXISTS with a subquery to find authors whose books have never been borrowed.
Task
Write a query that retrieves from the autorzy table (alias a) the imie and nazwisko columns of those authors who have books, but none of them has been borrowed. First use an EXISTS condition to check that the author has a book (ksiazki k, k.autor_id = a.id), then NOT EXISTS that no borrowing of that book exists (wypozyczenia w, w.ksiazka_id = k.id). Hint: use EXISTS with a nested NOT EXISTS.