MySQL这里不支持单行注释.会是什么原因呢? [英] MySQL is not supporting single line comments here. What would be the reason?
问题描述
这是我使用单行注释(使用-)时得到的:
Here is what I am getting when I use single line comment (using --):
错误1064(42000):您的SQL语法有错误
ERROR 1064 (42000): You have an error in your SQL syntax
实际上,我在过程中使用这些注释来显示行的确切功能.然后,我直接在MySQL命令行中进行检查,但出现此错误:
Actually I am using these comments in a procedure to show what exactly a 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
我需要配置一个文件来支持吗?如果我使用多行注释(使用/* Something */
),效果很好.
Do I need to configure a file to support this? It is working fine if I use multi-line comments (using /* Something */
).
我搜索并浏览了MySQL文档.它向我展示了它支持(-). 可能是什么错误?
I googled and went through MySQL documentation. In that it has shown me it supports ( -- ). What could be the error?
推荐答案
来自MySQL文档:
从-"序列到行尾.在MySQL中,-"(双破折号)注释样式要求第二个破折号后跟 至少一个空格或控制字符(例如空格,制表符, 换行符,依此类推).
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).
在--
之后需要一些空格字符,例如:
You need some space character after --
, for example:
mysql> select 1;-- test select
这篇关于MySQL这里不支持单行注释.会是什么原因呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!