MySQL does not support single-line comments here. What will be the reason?

Here is what I get when I use a single line comment (using - ):

ERROR 1064 (42000): You have a SQL syntax error

In fact, I use these comments in the procedure to show what exactly the line does. Then I checked directly at the MySQL command line, but I got this error:

mysql> select 1;--test select +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) -> ; check the manual that corresponds to your MySQL server version for the right syntax to use near '--test select' at line 1 

Do I need to configure a file to support this? This works fine if I use multi-line comments (using /* Something */ ).

I googled and looked at the MySQL documentation. That he showed me that he supports ( - ). What could be the mistake?

+7
command-line comments mysql mysqli
Jan 21 '13 at 9:48 on
source share
2 answers

From the MySQL documentation:

From the sequence β€œ-” to the end of the line. In MySQL, the comment style β€œ-” (double dash) requires that the second dash is followed by at least one space or control character (for example, space, tab, newline, etc.).

You need a space after -- , for example:

 mysql> select 1;-- test select 
+13
Jan 21 '13 at 9:55 on
source share
β€” -

Your syntax is incorrect - read about comment syntax .

Just add a space after -- :

 mysql> select 1; -- test select +---+ | 1 | +---+ | 1 | +---+ 1 row in set (0.00 sec) 
+5
Jan 21 '13 at 9:55 on
source share



All Articles