php - Getting many rows through joined tables -


i have id of album , i'd tracks album artists. album has many tracks. track has many producers (artists).

mysql structure

database structure

problem

i don't know if can in full mysql or if should add php instead.

edit : question wasn't clear enough. problem wasn't fact of doing query joined table tracks list of artists. can handle group_concat.

tutorial : http://www.mysqlperformanceblog.com/2006/09/04/group_concat-useful-group-by-extension/

it depends how need data. if you're more interested in artists can join tracks on albums , artists onto tracks. give record each artist.

select     ar.* albums al join tracks t     on t.album_id = al.album_id join produced p     on p.produced_track = t.track_id join artists ar     on ar.artist_id = p.produced_artist 

if you're more interested in tracks , need list artists same join use group_concat on artist name , group track id

select     t.*,     group_concat(distinct ar.name order ar.name separator ', ') artists albums al join tracks t     on t.album_id = al.album_id join produced p     on p.produced_track = t.track_id join artists ar     on ar.artist_id = p.produced_artist group t.track_id 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -