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 how code is already "parsed" by Stack Overflow:
It said that I need to use 4 spaces, or Ctrl + K to make the indentation. I tried both and killed more time for these attempts than I invested in formulating the question, but no luck. I tried using same indentation for all lines of my code.
The 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.
The 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
SELECT
keyword should be formatted as code. Each identifier or piece of code liketag_events.event_id
should be formatted as code.