I've been trying to get a query which would allow me to put all music genres of an event (Link table) in a single row but I have been quite unsuccessful so far; it constantly returns 2 rows with the same information about the event in each but changing the music genre entries at the LEFT JOIN. Here's my query:
SELECT
events.*
, music_genres_link.*
FROM events
LEFT JOIN music_genres_link
ON events.id = music_genres_link.event_id
WHERE events.id=1
ORDER BY date DESC
And here's what it returns:
How do I get these two rows together in a single one? I need both the genre_title and genre_id columns.
I'd like to get the whole event row and left join all the music genres found on the link table to the left of the result, as such:
[event result] [music_genre_1 (id, title)] [music_genre_2 (id, title)] etc