I have a problem incorporating a Group_Concat function in my SQL query. I have tried to work around it with PHP, but I would prefer to get it right with SQL instead. My code is below, I am using the latest version of MYSQL.
SELECT Main.Title, Main.DatePrint, Main.PerformanceDate, Main.Unsure_Sure, Main.Register, Main.notes,
VenueKey.Venue,AuthorKey.Author, CompanyKey.Company, PrintKey.Printer, SourceKey.Source
FROM Main INNER JOIN MainVenue
ON Main.MainID = MainVenue.ID_V
INNER JOIN VenueKey
ON MainVenue.VenueID = VenueKey.ID_V_K
INNER JOIN MainAuthor
ON Main.MainID = MainAuthor.ID_A
INNER JOIN AuthorKey
ON MainAuthor.AuthorID = AuthorKey.ID_A_K
INNER JOIN MainCompany
ON Main.MainID = MainCompany.ID_C
INNER JOIN CompanyKey
ON MainCompany.CompanyID = CompanyKey.ID_C_K
INNER JOIN MainPrinter
ON Main.MainID = MainPrinter.ID_P
INNER JOIN PrintKey
ON MainPrinter.PrinterID = PrintKey.ID_P_K
INNER JOIN MainSource
ON Main.MainID = MainSource.ID_S
INNER JOIN SourceKey
ON MainSource.SourceID = SourceKey.ID_S_K
Ideally I would like to use a Group_Concat on Author, Venue, and Company but I have been having a hard time getting it to work, with it instead returning a null value. Please let me know what if there is anything I can do to fix this.
Thanks.
You must be grouping the results in order for GROUP_CONCAT to have something to work with. Try something along the lines of:
to get a list of the authors with a concatenated list of venues and companies for example.