I create a simple data base on 3 tables: Author, that can has many Books, and Genre that also can has many Books.
I want to get all Genres of one Author using it authorId
. I wrote next nested SQL select:
SELECT genre.id, genre.genre_id, genre.genre_name, genre.genre_descr FROM (SELECT book.genre_id FROM book WHERE book.author_id = 7654) AS b JOIN genre WHERE b.genre_id = genre.genre_id;
It works good for me, but is it possible some minimize this select? For example, get rid of nested select?
Yes, I know, that the good solution is to create reference many to many beetwen genre and author, but it will add some complications...
Thanks!