I know --
means starting of comment in mysql. But what does ---
and ----
mean?? See my console log.
mysql> --
mysql> ---
->
-> ;
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 '-' at line 1
mysql> ----
->
-> ;
Query OK, 0 rows affected (0.00 sec)
I wrote an sql file that contains header comments started with ---
characters. Due to this next query does not run. It throws error. Like this.
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 '-' at line 1
There needs to be whitespace or a control character after the second dash. From the MySQL manual:
MySQL Server supports three comment styles:
From a
#
character to the end of the line.From a
--
sequence to the end of the line. In MySQL, the--
(double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on). This syntax differs slightly from standard SQL comment syntax, as discussed in Section 1.8.5.5, “--
as the Start of a Comment”.From a
/*
sequence to the following*/
sequence, as in the C programming language. This syntax enables a comment to extend over multiple lines because the beginning and closing sequences need not be on the same line.
(Emphasis mine.) And, as usual, this only applies to MySQL. :P
This nothing but syntax check error,
Other than '--', mysql considering everything as sql statement. Since
'---' is not a valid statement it's showing error.
that means there should be at least one space after '--' then only it will be considered as valid comment.
Hope this helps you,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With