gpt4 book ai didi

MySQL 在这里不支持单行注释。会是什么原因呢?

转载 作者:可可西里 更新时间:2023-11-01 06:35:01 24 4
gpt4 key购买 nike

这是我在使用单行注释(使用 --)时得到的结果:

ERROR 1064 (42000): You have an error in your SQL syntax

实际上,我在一个过程中使用这些注释来显示一行到底做了什么。然后直接在MySQL命令行查看,却报错:

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 */),它工作正常。

我用谷歌搜索并浏览了 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).

--后需要加空格,例如:

mysql> select 1;-- test select

关于MySQL 在这里不支持单行注释。会是什么原因呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14435989/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com