mysql - INNER JOIN SQL/PHP - Need a single row with array on column -
I have created a relational database for songs, musicians and songwriters.
My point is that some songs may be many songwriter or many musicians, so when I search for my database, then I would like to return a song back with an array of musicians or songwriters, if special There are more than one contributor in the song.
I am dragging data songs, composers [related to musicians for songs], composers, songwriter [songs written by songwriters], songwriter, details from many tables,
all this SQL The query has been brought with:
Select songs Song, show Showy, Composer Details Musicians, lyricistdetails.name Songwriter Song Musicians Join I Composers Musicians on Songs Join Details of Musicians Write on the musicians. Join musicians on musicians. Add songs to the songs of songs. Write lyrics on songwriter. Author: lyricistdetails.lyricistid JOIN shows on the show. Showint = songs.showid WHERE MATCH song title) AGAINST ('$ song name' in bullion mode)
For the moment, me
[0] = & Gt; StdClass Object ([Sopittal] => Maria [Showcate] => West Side Story [Composer] => Leonard Bernstein [songwriter] => Leonard Bernstein) [1] = & gt; Leonard Bernstein [songwriter] = & gt; Stefan Sondheim]
< P> If I ignore the song song song of the song song if I have more than one, then what is the best way to go about the result of returning as single lines with an array for the songwriter? You can use GROUP_CONCAT
, but be aware that There is a character limit in the group
SELECT songs.songtitle, show.showtitle, Group_ CONCAT (composer details.name) Musician, GroupConcat (songwriter V. N. Nam), composers on lyricist musicians from songwriter Join. Song = songs Join Musicians on Information on Musicians Composerid = composerdetails.composerid Join lyricists on songwriters. Song = songs on lyricists. Shows songs on songs. Show = song Songs where matching (song title) AGAINST ('$ song name' in boolean mode) by group. See the limit of characters in group_concat for
Comments
Post a Comment