1

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:

Post preview screenshot

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

6
  • 2
    What is “events.id events.title events.city_id tag_events.event_id tag_events.tag_id tags.id tags.title” supposed to mean? Why do you have this there? Those are not English sentences. This looks like unformatted code. The SELECT keyword should be formatted as code. Each identifier or piece of code like tag_events.event_id should be formatted as code. Commented Mar 17, 2022 at 14:40
  • Since there's no quality check on meta, you will be able to post the original markdown on here without getting blocked, and perhaps help us to review the issues.
    – Andrew T.
    Commented Mar 17, 2022 at 14:44
  • @Sebastian Simon this is not whole post. My current question is not on the topic of using MYSQL, it is only about pasting blocks of code into the stack overflow website. You can see whole code block. What is written above the code is not relevant to the question whatsoever
    – Alex R
    Commented Mar 17, 2022 at 14:47
  • @AndrewT. thanks for the Idea, I will pose whole question here, in case I won't be able so solve this formatting issue to post on the original section of the website
    – Alex R
    Commented Mar 17, 2022 at 14:48
  • @SebastianSimon > Each identifier or piece of code like tag_events.event_id should be formatted as code. Thanks, I did not know that. I thought I was supposed to mark as code only selected part
    – Alex R
    Commented Mar 17, 2022 at 14:49
  • FI, there are 4 TABs in it. Commented Mar 18, 2022 at 13:16

2 Answers 2

1
  • Put a blank line before and after the block of code.

  • The block of code seems to have only 1 or 2 spaces at the beginning; make it 4. If it is in a bullet list, make it 6 instead of 4. Example

    SELECT iiiii, WWWWW
        FROM foobar;
    
  • Use Edit to see what I typed.

1
  • Similarly backtics around in-line code.
    – Rick James
    Commented Mar 22, 2022 at 21:09
0

Thanks to the comments, the result is that I could not post my question because I had to outline all identifiers as code, not only the actual SELECT MySQL request.

1
  • Re "I had to outline all identifiers as code": That sounds incidental. I am not convinced. There most be a canonical meta question somewhere. Commented Mar 18, 2022 at 12:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .