Skip to main content
Active reading [<en.wiktionary.org/wiki/question#Noun> <http://stackoverflow.com/legal/trademark-guidance>]. More specific title (though it could probably be shorter). Removed historical information (e.g. ref. <meta.stackexchange.com/a/230693>) - the question should be as if it was written right now
Source Link
Peter Mortensen
  • 31.6k
  • 4
  • 22
  • 14

Formatting mysqlMySQL code in order to be able to submit a question

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:   

Post preview screenshot

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

Formatting mysql code

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 indentation. I tried both, killed for these attemts more time that I invested in formulating the quesion, but no luck. I tried using SAME indentation for all lines of my code

UPD: 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.


UPD2: 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

Formatting MySQL code in order to be able to submit a question

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

added 68 characters in body
Source Link
BDL
  • 22.1k
  • 8
  • 61
  • 85

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 indentation. I tried both, killed for these attemts more time that I invested in formulating the quesion, but no luck. I tried using SAME indentation for all lines of my code

UPD: 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.


UPD2: 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

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

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 indentation. I tried both, killed for these attemts more time that I invested in formulating the quesion, but no luck. I tried using SAME indentation for all lines of my code

UPD: 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.


UPD2: 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

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 indentation. I tried both, killed for these attemts more time that I invested in formulating the quesion, but no luck. I tried using SAME indentation for all lines of my code

UPD: 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.


UPD2: 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

Added text of my original post
Source Link

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 indentation. I tried both, killed for these attemts more time that I invested in formulating the quesion, but no luck. I tried using SAME indentation for all lines of my code

UPD: 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.


UPD2: 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

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 indentation. I tried both, killed for these attemts more time that I invested in formulating the quesion, but no luck. I tried using SAME indentation for all lines of my code

UPD: 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.

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 indentation. I tried both, killed for these attemts more time that I invested in formulating the quesion, but no luck. I tried using SAME indentation for all lines of my code

UPD: 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.


UPD2: 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

Source Link
Loading