any other solution except join?

any other solution except join?

any other solution except join?

Hi everyone, I’m beginner and doing my first steps so I have this DB

https://preview.redd.it/28lhbydu0aj61.png?width=1094&format=png&auto=webp&s=dc39e996b00ef1581bdab8dc3d5f408b9c58aa6e

I need to get customers by genre and the only thing that came out is join but it’s too big and I think in a big DB it will be totally ineffective

select main.customers.LastName, g.Name from customers left join invoices i on customers.CustomerId = i.CustomerId left join invoice_items ii on i.InvoiceId = ii.InvoiceId left join tracks t on ii.TrackId = t.TrackId left join genres g on t.GenreId = g.GenreId group by g.Name; 

So is it possible to write this query more elegant way without join or it’a common practice and the only way?

submitted by /u/MrFaffer
[link] [comments]


Go to Source of this post
Author Of this post: /u/MrFaffer
Title Of post: any other solution except join?
Author Link: {authorlink}