I can't make a post because Stack Overflow keeps insisting on some formatting, even though my code is already formatted.
This was a preview of my post, notice. Notice how code is already "parsed" by Stack overflow Overflow:
It said that I need to use 4 spaces, or Ctrl+KCtrl + K to make the indentation. I tried both, and killed for these attemts more time thatfor these attempts than I invested in formulating the quesionquestion, but no luck. I tried using SAMEsame indentation for all lines of my code.
UPD: theThe error is:
Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.
UPD2: TheThe whole post is:
I want to make a list of "events" and see list of correlated tags for each event. The thing is that tags stored in another table that connects tags with events via Many-To-Many relation
These tables and fields are used in my example
events.id events.title events.city_id tag_events.event_id tag_events.tag_id tags.id tags.title
This is my attempt:
SELECT events.id, events.title, SELECT (GROUP_CONCAT(tags.title) FROM events LEFT JOIN tag_events ON events.id = tag_events.event_id JOIN tags ON tag_events.tag_id = tags.id) 'List of tags' FROM events WHERE events.city_id = 111 GROUP BY events.id
The result I get is list of events with same list of tags for each event (incorrect output) I don't know how to implement idea to connect "outer" SELECT statement with "included" SELECT statement via fiels tag_events.event_id