Because the link you provided clearly explains that -- is the standard SQL comment separator. When MySQL departs from the standard, a space after -- required, which will be recognized as a comment. "Standard" SQL does not require this.
To provide an example, in the following code it -- recognized as a comment token:
mysql> CREATE TABLE T(C int); -- This is my new table Query OK, 0 rows affected (0.18 sec)
But note that after -- interactive interpreter erroneously works:
mysql> CREATE TABLE T(C int); --This is my new table Query OK, 0 rows affected (0.24 sec) -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '--This is my new table' at line 1
MySQL supports some other comment format to adapt to the habits of various programmers: # like many script languages ββand /* ... */ like C. It is very amazing that // is not part of them yet.
mysql> CREATE TABLE T(C int); Query OK, 0 rows affected (0.22 sec) mysql> CREATE TABLE T(C int); # This is my new table Query OK, 0 rows affected (0.24 sec)
source share