MySQL 错误:您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在附近使用的正确语法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5703441/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL error: 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
提问by Gnanendra
I have the Stored procedure like this:
我有这样的存储过程:
CREATE PROCEDURE ProG()
BEGIN
SELECT * FROM `hs_hr_employee_leave_quota`;
END
But it gives the error:
但它给出了错误:
#1064- 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 3
#1064- 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取在第 3 行的 '' 附近使用的正确语法
What does the error mean? What is wrong with line number 2?
错误是什么意思?第 2 行有什么问题?
回答by Nicola Cossu
You have to change delimiter before using triggers, stored procedures and so on.
您必须在使用触发器、存储过程等之前更改分隔符。
delimiter //
create procedure ProG()
begin
SELECT * FROM hs_hr_employee_leave_quota;
end;//
delimiter ;
回答by Eric Leschinski
How to find out what this MySQL Error is trying to say:
如何找出这个 MySQL 错误试图说的内容:
#1064 - You have an error in your SQL syntax;
This error has no clues in it. You have to double check all of these items to see where your mistake is:
这个错误没有任何线索。你必须仔细检查所有这些项目,看看你的错误在哪里:
- You have omitted, or included an unnecessary symbol:
!@#$%^&*()-_=+[]{}\|;:'",<>/? - A misplaced, missing or unnecessary keyword:
select,into, or countless others. - You have unicode characters that look like ascii characters in your query but are not recognized.
- Misplaced, missing or unnecessary whitespace or newlines between keywords.
- Unmatched single quotes, double quotes, parenthesis or braces.
- 您省略了或包含了不必要的符号:
!@#$%^&*()-_=+[]{}\|;:'",<>/? - 放错位置,丢失或不必要的关键字:
select,into或无数人。 - 您的查询中有一些看起来像 ascii 字符但无法识别的 unicode 字符。
- 关键字之间错位、缺失或不必要的空格或换行符。
- 不匹配的单引号、双引号、括号或大括号。
Take away as much as you can from the broken query until it starts working. And then use PostgreSQL next time that has a sane syntax reporting system.
尽可能多地从损坏的查询中删除,直到它开始工作。然后下次使用具有健全语法报告系统的 PostgreSQL。
回答by ypercube??
Delimiters, delimiters...
分隔符,分隔符...
You really need them when there are multiple statements in your procedure. (in other words, do you have a ;in your code and then more statements/commands? Then, you need to use delimiters).
当您的过程中有多个语句时,您确实需要它们。(换句话说,;您的代码中是否有 a和更多的语句/命令?然后,您需要使用分隔符)。
For such a simpler rpocedure as yours though, you could just do:
对于像您这样更简单的程序,您可以这样做:
CREATE PROCEDURE ProG()
SELECT * FROM `hs_hr_employee_leave_quota`;
回答by sherin.k
This might be a memmory issue on mysql try to increase max_allowed_packet in my.ini
这可能是 mysql 的内存问题尝试增加 my.ini 中的 max_allowed_packet

